Created
August 24, 2022 12:49
-
-
Save loretoparisi/8fa61d791742789280ff22e669e4e160 to your computer and use it in GitHub Desktop.
Stable Diffusion Pipeline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# make sure you're logged in with `huggingface-cli login` | |
import os | |
from torch import autocast | |
from diffusers import StableDiffusionPipeline, LMSDiscreteScheduler | |
lms = LMSDiscreteScheduler( | |
beta_start=0.00085, | |
beta_end=0.012, | |
beta_schedule="scaled_linear" | |
) | |
pipe = StableDiffusionPipeline.from_pretrained( | |
"CompVis/stable-diffusion-v1-3", | |
scheduler=lms, | |
use_auth_token=True, | |
cache_dir=os.getenv("cache_dir", "./models") | |
).to("cpu") | |
prompt = "a photo of an astronaut riding a horse on mars" | |
with autocast("cpu"): | |
image = pipe(prompt)["sample"][0] | |
image.save("astronaut_rides_horse.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment