tools / run_local.py
patrickvonplaten's picture
up
4861382
raw
history blame contribute delete
911 Bytes
#!/usr/bin/env python3
from diffusers import (
SASolverScheduler,
StableDiffusionPipeline,
KDPM2DiscreteScheduler,
StableDiffusionImg2ImgPipeline,
HeunDiscreteScheduler,
KDPM2AncestralDiscreteScheduler,
DDIMScheduler,
)
import time
import torch
import sys
from pathlib import Path
# path = sys.argv[1]
path = "runwayml/stable-diffusion-v1-5"
device = "mps"
pipe = StableDiffusionPipeline.from_pretrained(path, torch_dtype=torch.float16)
pipe.scheduler = SASolverScheduler.from_config(pipe.scheduler.config)
pipe.to(device)
prompt = "A lion in galaxies, spirals, nebulae, stars, smoke, iridescent, intricate detail, octane render, 8k"
start_time = time.time()
generator = torch.Generator(device=device).manual_seed(0)
images = pipe(
prompt=prompt, generator=generator, num_images_per_prompt=1, num_inference_steps=30
).images
print(time.time() - start_time)
images[0].show()