Skip to content

Instantly share code, notes, and snippets.

@esmarkowski
Last active September 7, 2022 01:08
Show Gist options
  • Save esmarkowski/2555261a5f50f723cb71163a09f1c89c to your computer and use it in GitHub Desktop.
Save esmarkowski/2555261a5f50f723cb71163a09f1c89c to your computer and use it in GitHub Desktop.
import torch
from torch import autocast
from diffusers import StableDiffusionPipeline
model_id = "CompVis/stable-diffusion-v1-4"
device = "cuda"
pipe = StableDiffusionPipeline.from_pretrained(model_id, use_auth_token=True)
pipe = pipe.to(device)
prompt = " ".join([subject, setting, style])
with autocast("cuda"):
image = pipe(prompt, guidance_scale=7.5)["sample"][0]
image.save( prompt + ".png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment