Created
November 21, 2022 21:17
-
-
Save amrakm/9d66490d302768bae418949e0c5f968e to your computer and use it in GitHub Desktop.
reproducible stablediffusion using seeds
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 | |
pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", use_auth_token=True).to("cuda") | |
seed= 111111 | |
height =512 | |
width = 512 | |
device = 'cuda' | |
generator = torch.Generator(device=device) | |
generator = generator.manual_seed(seed) | |
latents = torch.randn( | |
(1, pipe.unet.in_channels, height // 8, width // 8), | |
generator = generator, | |
device = device | |
) | |
p = pipe("fruits basket", | |
latents=latents) | |
img=p.images[0] | |
img |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment