Skip to content

Instantly share code, notes, and snippets.

@Arkoniak
Created September 2, 2022 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arkoniak/92c213ba1c15aa9f5967680e225ac9fa to your computer and use it in GitHub Desktop.
Save Arkoniak/92c213ba1c15aa9f5967680e225ac9fa to your computer and use it in GitHub Desktop.
import torch
from diffusers import StableDiffusionPipeline
access_token = "<access token>"
# make sure you're logged in with `huggingface-cli login`
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", revision="fp16", torch_dtype=torch.float16, use_auth_token=access_token)
pipe = pipe.to("cuda")
# Image generation
from torch import autocast
prompt = "detailed photorealistic image of the beautiful woman in wooden armor with golden crown who has big dragon wings and looks directly at you"
with autocast("cuda"):
for i in range(20):
image = pipe(prompt)["sample"][0] # image here is in [PIL format](https://pillow.readthedocs.io/en/stable/)
image.save(f"dragon_woman_{i}.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment