Skip to content

Instantly share code, notes, and snippets.

@amrakm
Created November 21, 2022 21:17
Show Gist options
  • Save amrakm/9d66490d302768bae418949e0c5f968e to your computer and use it in GitHub Desktop.
Save amrakm/9d66490d302768bae418949e0c5f968e to your computer and use it in GitHub Desktop.
reproducible stablediffusion using seeds
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