tools / README.md
patrickvonplaten's picture
Update README.md
dbc57d2
|
raw
history blame
1.69 kB

Diffusers Tools

This is a collection of scripts that can be useful for various tasks related to the diffusers library

Test against original checkpoints

It's very important to have visually the exact same results as the original code bases.!

E.g. to make use diffusers is identical to the original CompVis codebase, you can run the following script in the original CompVis codebase:

  1. Download the original SD-1-4 checkpoint and put it in the correct folder following the instructions on: https://github.com/CompVis/stable-diffusion

  2. Run the following command

python scripts/txt2img.py --prompt "a photograph of an astronaut riding a horse" --seed 0 --n_samples 1 --n_rows 1 --n_iter 1

and compare this to the same command in diffusers:

from diffusers import DiffusionPipeline, StableDiffusionPipeline, DDIMScheduler
import torch

#  python scripts/txt2img.py --prompt "a photograph of an astronaut riding a horse" --seed 0 --n_samples 1 --n_rows 1 --n_iter 1
seed = 0

prompt = "a photograph of an astronaut riding a horse"
pipe = DiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", torch_dtype=torch.float16)

pipe = pipe.to("cuda")
pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config)
torch.manual_seed(0)
image = pipe(prompt, num_inference_steps=50).images[0]

image.save("/home/patrick_huggingface_co/images/aa_comp.png")

Both commands should give the following image on a V100:

image