Created
September 2, 2022 19:27
-
-
Save Arkoniak/92c213ba1c15aa9f5967680e225ac9fa to your computer and use it in GitHub Desktop.
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
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