Commit
·
2438a7d
1
Parent(s):
69f6fc2
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Diffusers Tools
|
| 2 |
+
|
| 3 |
+
This is a collection of scripts that can be useful for various tasks related to the [diffusers library](https://github.com/huggingface/diffusers)
|
| 4 |
+
|
| 5 |
+
## Test against original checkpoints
|
| 6 |
+
|
| 7 |
+
**It's very important to have visually the exact same results as the original code bases.!**
|
| 8 |
+
|
| 9 |
+
E.g. to make use `diffusers` is identical to the original [CompVis codebase](https://github.com/CompVis/stable-diffusion), you can run the following script in the original CompVis codebase:
|
| 10 |
+
|
| 11 |
+
1. Download the original [SD-1-4 checkpoint](https://huggingface.co/CompVis/stable-diffusion-v1-4) and put it in the correct folder following the instructions on: https://github.com/CompVis/stable-diffusion
|
| 12 |
+
|
| 13 |
+
2. Run the following command
|
| 14 |
+
```
|
| 15 |
+
python scripts/txt2img.py --prompt "a photograph of an astronaut riding a horse" --seed 0 --n_samples 1 --n_rows 1 --n_iter 1
|
| 16 |
+
```
|
| 17 |
+
|
| 18 |
+
and compare this to the same command in diffusers:
|
| 19 |
+
|
| 20 |
+
```python
|
| 21 |
+
from diffusers import DiffusionPipeline, StableDiffusionPipeline, DDIMScheduler
|
| 22 |
+
import torch
|
| 23 |
+
|
| 24 |
+
# python scripts/txt2img.py --prompt "a photograph of an astronaut riding a horse" --seed 0 --n_samples 1 --n_rows 1 --n_iter 1
|
| 25 |
+
seed = 0
|
| 26 |
+
|
| 27 |
+
prompt = "a photograph of an astronaut riding a horse"
|
| 28 |
+
pipe = DiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", torch_dtype=torch.float16)
|
| 29 |
+
|
| 30 |
+
pipe = pipe.to("cuda")
|
| 31 |
+
pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config)
|
| 32 |
+
torch.manual_seed(0)
|
| 33 |
+
image = pipe(prompt, num_inference_steps=50).images[0]
|
| 34 |
+
|
| 35 |
+
image.save("/home/patrick_huggingface_co/images/aa_comp.png")
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
Both commands should give the following image on a V100:
|
| 39 |
+
|