|
|
|
from diffusers import ( |
|
SASolverScheduler, |
|
StableDiffusionPipeline, |
|
KDPM2DiscreteScheduler, |
|
StableDiffusionImg2ImgPipeline, |
|
HeunDiscreteScheduler, |
|
KDPM2AncestralDiscreteScheduler, |
|
DDIMScheduler, |
|
) |
|
import time |
|
import torch |
|
import sys |
|
from pathlib import Path |
|
|
|
|
|
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() |
|
|