CoolFace
Modelpublic

diffusers/tools

sourceHugging Facecreativeml-openrail-mupdated 3y agoView on Hugging Face
11likes27downloads
run_local_sag.py35 linesDownload Raw Back to root
1#!/usr/bin/env python32from diffusers import (3    StableDiffusionSAGPipeline,4    StableDiffusionPipeline,5    KDPM2DiscreteScheduler,6    StableDiffusionImg2ImgPipeline,7    HeunDiscreteScheduler,8    KDPM2AncestralDiscreteScheduler,9    DDIMScheduler,10)11import time12import torch13import sys14from pathlib import Path15 16# path = sys.argv[1]17path = "runwayml/stable-diffusion-v1-5"18device = "cpu"19dtype = torch.float3220 21pipe = StableDiffusionSAGPipeline.from_pretrained(path, torch_dtype=dtype)22# pipe.scheduler = SASolverScheduler.from_config(pipe.scheduler.config)23pipe.to(device)24 25prompt = "A lion in galaxies, spirals, nebulae, stars, smoke, iridescent, intricate detail, octane render, 8k"26 27start_time = time.time()28generator = torch.Generator(device=device).manual_seed(0)29images = pipe(30    prompt=prompt, generator=generator, num_images_per_prompt=1, num_inference_steps=3031).images32print(time.time() - start_time)33 34images[0].show()35