Dhdb commited on
Commit
a121792
·
verified ·
1 Parent(s): b9d4a6d

Upload 137 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +8 -0
  2. .gitignore +5 -0
  3. LICENSE +14 -0
  4. README.md +209 -12
  5. Stable_Diffusion_v1_Model_Card.md +140 -0
  6. app.py +221 -0
  7. assets/a-painting-of-a-fire.png +0 -0
  8. assets/a-photograph-of-a-fire.png +0 -0
  9. assets/a-shirt-with-a-fire-printed-on-it.png +0 -0
  10. assets/a-shirt-with-the-inscription-'fire'.png +0 -0
  11. assets/a-watercolor-painting-of-a-fire.png +0 -0
  12. assets/birdhouse.png +0 -0
  13. assets/fire.png +0 -0
  14. assets/inpainting.png +0 -0
  15. assets/logo.jpeg +0 -0
  16. assets/modelfigure.png +0 -0
  17. assets/rdm-preview.jpg +0 -0
  18. assets/reconstruction1.png +0 -0
  19. assets/reconstruction2.png +0 -0
  20. assets/results.gif +3 -0
  21. assets/stable-samples/img2img/mountains-1.png +0 -0
  22. assets/stable-samples/img2img/mountains-2.png +0 -0
  23. assets/stable-samples/img2img/mountains-3.png +0 -0
  24. assets/stable-samples/img2img/sketch-mountains-input.jpg +0 -0
  25. assets/stable-samples/img2img/upscaling-in.png +3 -0
  26. assets/stable-samples/img2img/upscaling-out.png +3 -0
  27. assets/stable-samples/txt2img/000002025.png +0 -0
  28. assets/stable-samples/txt2img/000002035.png +0 -0
  29. assets/stable-samples/txt2img/merged-0005.png +3 -0
  30. assets/stable-samples/txt2img/merged-0006.png +3 -0
  31. assets/stable-samples/txt2img/merged-0007.png +3 -0
  32. assets/the-earth-is-on-fire,-oil-on-canvas.png +0 -0
  33. assets/txt2img-convsample.png +0 -0
  34. assets/txt2img-preview.png +3 -0
  35. assets/v1-variants-scores.jpg +0 -0
  36. configs/autoencoder/autoencoder_kl_16x16x16.yaml +54 -0
  37. configs/autoencoder/autoencoder_kl_32x32x4.yaml +53 -0
  38. configs/autoencoder/autoencoder_kl_64x64x3.yaml +54 -0
  39. configs/autoencoder/autoencoder_kl_8x8x64.yaml +53 -0
  40. configs/latent-diffusion/celebahq-ldm-vq-4.yaml +86 -0
  41. configs/latent-diffusion/cin-ldm-vq-f8.yaml +98 -0
  42. configs/latent-diffusion/cin256-v2.yaml +68 -0
  43. configs/latent-diffusion/ffhq-ldm-vq-4.yaml +85 -0
  44. configs/latent-diffusion/lsun_bedrooms-ldm-vq-4.yaml +85 -0
  45. configs/latent-diffusion/lsun_churches-ldm-kl-8.yaml +91 -0
  46. configs/latent-diffusion/txt2img-1p4B-eval.yaml +71 -0
  47. configs/retrieval-augmented-diffusion/768x768.yaml +68 -0
  48. configs/stable-diffusion/v1-inference.yaml +70 -0
  49. data/DejaVuSans.ttf +0 -0
  50. data/example_conditioning/superresolution/sample_0.jpg +0 -0
.gitattributes CHANGED
@@ -33,3 +33,11 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ assets/results.gif filter=lfs diff=lfs merge=lfs -text
37
+ assets/stable-samples/img2img/upscaling-in.png filter=lfs diff=lfs merge=lfs -text
38
+ assets/stable-samples/img2img/upscaling-out.png filter=lfs diff=lfs merge=lfs -text
39
+ assets/stable-samples/txt2img/merged-0005.png filter=lfs diff=lfs merge=lfs -text
40
+ assets/stable-samples/txt2img/merged-0006.png filter=lfs diff=lfs merge=lfs -text
41
+ assets/stable-samples/txt2img/merged-0007.png filter=lfs diff=lfs merge=lfs -text
42
+ assets/txt2img-preview.png filter=lfs diff=lfs merge=lfs -text
43
+ data/imagenet_train_hr_indices.p filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ __pycache__/
2
+ outputs/
3
+ models/
4
+ *.pth
5
+ *.egg-info/
LICENSE ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ All rights reserved by the authors.
2
+ You must not distribute the weights provided to you directly or indirectly without explicit consent of the authors.
3
+ You must not distribute harmful, offensive, dehumanizing content or otherwise harmful representations of people or their environments, cultures, religions, etc. produced with the model weights
4
+ or other generated content described in the "Misuse and Malicious Use" section in the model card.
5
+ The model weights are provided for research purposes only.
6
+
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
9
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
10
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
11
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
12
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
13
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
14
+ SOFTWARE.
README.md CHANGED
@@ -1,12 +1,209 @@
1
- ---
2
- title: Test Webui Hd
3
- emoji: 🐢
4
- colorFrom: gray
5
- colorTo: purple
6
- sdk: gradio
7
- sdk_version: 4.41.0
8
- app_file: app.py
9
- pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Stable Diffusion
2
+ *Stable Diffusion was made possible thanks to a collaboration with [Stability AI](https://stability.ai/) and [Runway](https://runwayml.com/) and builds upon our previous work:*
3
+
4
+ [**High-Resolution Image Synthesis with Latent Diffusion Models**](https://ommer-lab.com/research/latent-diffusion-models/)<br/>
5
+ [Robin Rombach](https://github.com/rromb)\*,
6
+ [Andreas Blattmann](https://github.com/ablattmann)\*,
7
+ [Dominik Lorenz](https://github.com/qp-qp)\,
8
+ [Patrick Esser](https://github.com/pesser),
9
+ [Björn Ommer](https://hci.iwr.uni-heidelberg.de/Staff/bommer)<br/>
10
+
11
+ **CVPR '22 Oral**
12
+
13
+ which is available on [GitHub](https://github.com/CompVis/latent-diffusion). PDF at [arXiv](https://arxiv.org/abs/2112.10752). Please also visit our [Project page](https://ommer-lab.com/research/latent-diffusion-models/).
14
+
15
+ ![txt2img-stable2](assets/stable-samples/txt2img/merged-0006.png)
16
+ [Stable Diffusion](#stable-diffusion-v1) is a latent text-to-image diffusion
17
+ model.
18
+ Thanks to a generous compute donation from [Stability AI](https://stability.ai/) and support from [LAION](https://laion.ai/), we were able to train a Latent Diffusion Model on 512x512 images from a subset of the [LAION-5B](https://laion.ai/blog/laion-5b/) database.
19
+ Similar to Google's [Imagen](https://arxiv.org/abs/2205.11487),
20
+ this model uses a frozen CLIP ViT-L/14 text encoder to condition the model on text prompts.
21
+ With its 860M UNet and 123M text encoder, the model is relatively lightweight and runs on a GPU with at least 10GB VRAM.
22
+ See [this section](#stable-diffusion-v1) below and the [model card](https://huggingface.co/CompVis/stable-diffusion).
23
+
24
+
25
+ ## Requirements
26
+ A suitable [conda](https://conda.io/) environment named `ldm` can be created
27
+ and activated with:
28
+
29
+ ```
30
+ conda env create -f environment.yaml
31
+ conda activate ldm
32
+ ```
33
+
34
+ You can also update an existing [latent diffusion](https://github.com/CompVis/latent-diffusion) environment by running
35
+
36
+ ```
37
+ conda install pytorch torchvision -c pytorch
38
+ pip install transformers==4.19.2
39
+ pip install -e .
40
+ ```
41
+
42
+
43
+ ## Stable Diffusion v1
44
+
45
+ Stable Diffusion v1 refers to a specific configuration of the model
46
+ architecture that uses a downsampling-factor 8 autoencoder with an 860M UNet
47
+ and CLIP ViT-L/14 text encoder for the diffusion model. The model was pretrained on 256x256 images and
48
+ then finetuned on 512x512 images.
49
+
50
+ *Note: Stable Diffusion v1 is a general text-to-image diffusion model and therefore mirrors biases and (mis-)conceptions that are present
51
+ in its training data.
52
+ Details on the training procedure and data, as well as the intended use of the model can be found in the corresponding [model card](https://huggingface.co/CompVis/stable-diffusion).
53
+ Research into the safe deployment of general text-to-image models is an ongoing effort. To prevent misuse and harm, we currently provide access to the checkpoints only for [academic research purposes upon request](https://stability.ai/academia-access-form).
54
+ **This is an experiment in safe and community-driven publication of a capable and general text-to-image model. We are working on a public release with a more permissive license that also incorporates ethical considerations.***
55
+
56
+ [Request access to Stable Diffusion v1 checkpoints for academic research](https://stability.ai/academia-access-form)
57
+
58
+ ### Weights
59
+
60
+ We currently provide three checkpoints, `sd-v1-1.ckpt`, `sd-v1-2.ckpt` and `sd-v1-3.ckpt`,
61
+ which were trained as follows,
62
+
63
+ - `sd-v1-1.ckpt`: 237k steps at resolution `256x256` on [laion2B-en](https://huggingface.co/datasets/laion/laion2B-en).
64
+ 194k steps at resolution `512x512` on [laion-high-resolution](https://huggingface.co/datasets/laion/laion-high-resolution) (170M examples from LAION-5B with resolution `>= 1024x1024`).
65
+ - `sd-v1-2.ckpt`: Resumed from `sd-v1-1.ckpt`.
66
+ 515k steps at resolution `512x512` on "laion-improved-aesthetics" (a subset of laion2B-en,
67
+ filtered to images with an original size `>= 512x512`, estimated aesthetics score `> 5.0`, and an estimated watermark probability `< 0.5`. The watermark estimate is from the LAION-5B metadata, the aesthetics score is estimated using an [improved aesthetics estimator](https://github.com/christophschuhmann/improved-aesthetic-predictor)).
68
+ - `sd-v1-3.ckpt`: Resumed from `sd-v1-2.ckpt`. 195k steps at resolution `512x512` on "laion-improved-aesthetics" and 10\% dropping of the text-conditioning to improve [classifier-free guidance sampling](https://arxiv.org/abs/2207.12598).
69
+
70
+ Evaluations with different classifier-free guidance scales (1.5, 2.0, 3.0, 4.0,
71
+ 5.0, 6.0, 7.0, 8.0) and 50 PLMS sampling
72
+ steps show the relative improvements of the checkpoints:
73
+ ![sd evaluation results](assets/v1-variants-scores.jpg)
74
+
75
+
76
+
77
+ ### Text-to-Image with Stable Diffusion
78
+ ![txt2img-stable2](assets/stable-samples/txt2img/merged-0005.png)
79
+ ![txt2img-stable2](assets/stable-samples/txt2img/merged-0007.png)
80
+
81
+ Stable Diffusion is a latent diffusion model conditioned on the (non-pooled) text embeddings of a CLIP ViT-L/14 text encoder.
82
+
83
+
84
+ #### Sampling Script
85
+
86
+ After [obtaining the weights](#weights), link them
87
+ ```
88
+ mkdir -p models/ldm/stable-diffusion-v1/
89
+ ln -s <path/to/model.ckpt> models/ldm/stable-diffusion-v1/model.ckpt
90
+ ```
91
+ and sample with
92
+ ```
93
+ python scripts/txt2img.py --prompt "a photograph of an astronaut riding a horse" --plms
94
+ ```
95
+
96
+ By default, this uses a guidance scale of `--scale 7.5`, [Katherine Crowson's implementation](https://github.com/CompVis/latent-diffusion/pull/51) of the [PLMS](https://arxiv.org/abs/2202.09778) sampler,
97
+ and renders images of size 512x512 (which it was trained on) in 50 steps. All supported arguments are listed below (type `python scripts/txt2img.py --help`).
98
+
99
+ ```commandline
100
+ usage: txt2img.py [-h] [--prompt [PROMPT]] [--outdir [OUTDIR]] [--skip_grid] [--skip_save] [--ddim_steps DDIM_STEPS] [--plms] [--laion400m] [--fixed_code] [--ddim_eta DDIM_ETA] [--n_iter N_ITER] [--H H] [--W W] [--C C] [--f F] [--n_samples N_SAMPLES] [--n_rows N_ROWS]
101
+ [--scale SCALE] [--from-file FROM_FILE] [--config CONFIG] [--ckpt CKPT] [--seed SEED] [--precision {full,autocast}]
102
+
103
+ optional arguments:
104
+ -h, --help show this help message and exit
105
+ --prompt [PROMPT] the prompt to render
106
+ --outdir [OUTDIR] dir to write results to
107
+ --skip_grid do not save a grid, only individual samples. Helpful when evaluating lots of samples
108
+ --skip_save do not save individual samples. For speed measurements.
109
+ --ddim_steps DDIM_STEPS
110
+ number of ddim sampling steps
111
+ --plms use plms sampling
112
+ --laion400m uses the LAION400M model
113
+ --fixed_code if enabled, uses the same starting code across samples
114
+ --ddim_eta DDIM_ETA ddim eta (eta=0.0 corresponds to deterministic sampling
115
+ --n_iter N_ITER sample this often
116
+ --H H image height, in pixel space
117
+ --W W image width, in pixel space
118
+ --C C latent channels
119
+ --f F downsampling factor
120
+ --n_samples N_SAMPLES
121
+ how many samples to produce for each given prompt. A.k.a. batch size
122
+ --n_rows N_ROWS rows in the grid (default: n_samples)
123
+ --scale SCALE unconditional guidance scale: eps = eps(x, empty) + scale * (eps(x, cond) - eps(x, empty))
124
+ --from-file FROM_FILE
125
+ if specified, load prompts from this file
126
+ --config CONFIG path to config which constructs model
127
+ --ckpt CKPT path to checkpoint of model
128
+ --seed SEED the seed (for reproducible sampling)
129
+ --precision {full,autocast}
130
+ evaluate at this precision
131
+
132
+ ```
133
+ Note: The inference config for all v1 versions is designed to be used with EMA-only checkpoints.
134
+ For this reason `use_ema=False` is set in the configuration, otherwise the code will try to switch from
135
+ non-EMA to EMA weights. If you want to examine the effect of EMA vs no EMA, we provide "full" checkpoints
136
+ which contain both types of weights. For these, `use_ema=False` will load and use the non-EMA weights.
137
+
138
+
139
+ #### Diffusers Integration
140
+
141
+ Another way to download and sample Stable Diffusion is by using the [diffusers library](https://github.com/huggingface/diffusers/tree/main#new--stable-diffusion-is-now-fully-compatible-with-diffusers)
142
+ ```py
143
+ # make sure you're logged in with `huggingface-cli login`
144
+ from torch import autocast
145
+ from diffusers import StableDiffusionPipeline, LMSDiscreteScheduler
146
+
147
+ pipe = StableDiffusionPipeline.from_pretrained(
148
+ "CompVis/stable-diffusion-v1-3-diffusers",
149
+ use_auth_token=True
150
+ )
151
+
152
+ prompt = "a photo of an astronaut riding a horse on mars"
153
+ with autocast("cuda"):
154
+ image = pipe(prompt)["sample"][0]
155
+
156
+ image.save("astronaut_rides_horse.png")
157
+ ```
158
+
159
+
160
+
161
+ ### Image Modification with Stable Diffusion
162
+
163
+ By using a diffusion-denoising mechanism as first proposed by [SDEdit](https://arxiv.org/abs/2108.01073), the model can be used for different
164
+ tasks such as text-guided image-to-image translation and upscaling. Similar to the txt2img sampling script,
165
+ we provide a script to perform image modification with Stable Diffusion.
166
+
167
+ The following describes an example where a rough sketch made in [Pinta](https://www.pinta-project.com/) is converted into a detailed artwork.
168
+ ```
169
+ python scripts/img2img.py --prompt "A fantasy landscape, trending on artstation" --init-img <path-to-img.jpg> --strength 0.8
170
+ ```
171
+ Here, strength is a value between 0.0 and 1.0, that controls the amount of noise that is added to the input image.
172
+ Values that approach 1.0 allow for lots of variations but will also produce images that are not semantically consistent with the input. See the following example.
173
+
174
+ **Input**
175
+
176
+ ![sketch-in](assets/stable-samples/img2img/sketch-mountains-input.jpg)
177
+
178
+ **Outputs**
179
+
180
+ ![out3](assets/stable-samples/img2img/mountains-3.png)
181
+ ![out2](assets/stable-samples/img2img/mountains-2.png)
182
+
183
+ This procedure can, for example, also be used to upscale samples from the base model.
184
+
185
+
186
+ ## Comments
187
+
188
+ - Our codebase for the diffusion models builds heavily on [OpenAI's ADM codebase](https://github.com/openai/guided-diffusion)
189
+ and [https://github.com/lucidrains/denoising-diffusion-pytorch](https://github.com/lucidrains/denoising-diffusion-pytorch).
190
+ Thanks for open-sourcing!
191
+
192
+ - The implementation of the transformer encoder is from [x-transformers](https://github.com/lucidrains/x-transformers) by [lucidrains](https://github.com/lucidrains?tab=repositories).
193
+
194
+
195
+ ## BibTeX
196
+
197
+ ```
198
+ @misc{rombach2021highresolution,
199
+ title={High-Resolution Image Synthesis with Latent Diffusion Models},
200
+ author={Robin Rombach and Andreas Blattmann and Dominik Lorenz and Patrick Esser and Björn Ommer},
201
+ year={2021},
202
+ eprint={2112.10752},
203
+ archivePrefix={arXiv},
204
+ primaryClass={cs.CV}
205
+ }
206
+
207
+ ```
208
+
209
+
Stable_Diffusion_v1_Model_Card.md ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Stable Diffusion v1 Model Card
2
+ This model card focuses on the model associated with the Stable Diffusion model, available [here](https://github.com/CompVis/stable-diffusion).
3
+
4
+ ## Model Details
5
+ - **Developed by:** Robin Rombach, Patrick Esser
6
+ - **Model type:** Diffusion-based text-to-image generation model
7
+ - **Language(s):** English
8
+ - **License:** [Proprietary](LICENSE)
9
+ - **Model Description:** This is a model that can be used to generate and modify images based on text prompts. It is a [Latent Diffusion Model](https://arxiv.org/abs/2112.10752) that uses a fixed, pretrained text encoder ([CLIP ViT-L/14](https://arxiv.org/abs/2103.00020)) as suggested in the [Imagen paper](https://arxiv.org/abs/2205.11487).
10
+ - **Resources for more information:** [GitHub Repository](https://github.com/CompVis/stable-diffusion), [Paper](https://arxiv.org/abs/2112.10752).
11
+ - **Cite as:**
12
+
13
+ @InProceedings{Rombach_2022_CVPR,
14
+ author = {Rombach, Robin and Blattmann, Andreas and Lorenz, Dominik and Esser, Patrick and Ommer, Bj\"orn},
15
+ title = {High-Resolution Image Synthesis With Latent Diffusion Models},
16
+ booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
17
+ month = {June},
18
+ year = {2022},
19
+ pages = {10684-10695}
20
+ }
21
+
22
+ # Uses
23
+
24
+ ## Direct Use
25
+ The model is intended for research purposes only. Possible research areas and
26
+ tasks include
27
+
28
+ - Safe deployment of models which have the potential to generate harmful content.
29
+ - Probing and understanding the limitations and biases of generative models.
30
+ - Generation of artworks and use in design and other artistic processes.
31
+ - Applications in educational or creative tools.
32
+ - Research on generative models.
33
+
34
+ Excluded uses are described below.
35
+
36
+ ### Misuse, Malicious Use, and Out-of-Scope Use
37
+ _Note: This section is taken from the [DALLE-MINI model card](https://huggingface.co/dalle-mini/dalle-mini), but applies in the same way to Stable Diffusion v1_.
38
+
39
+
40
+ The model should not be used to intentionally create or disseminate images that create hostile or alienating environments for people. This includes generating images that people would foreseeably find disturbing, distressing, or offensive; or content that propagates historical or current stereotypes.
41
+ #### Out-of-Scope Use
42
+ The model was not trained to be factual or true representations of people or events, and therefore using the model to generate such content is out-of-scope for the abilities of this model.
43
+ #### Misuse and Malicious Use
44
+ Using the model to generate content that is cruel to individuals is a misuse of this model. This includes, but is not limited to:
45
+
46
+ - Generating demeaning, dehumanizing, or otherwise harmful representations of people or their environments, cultures, religions, etc.
47
+ - Intentionally promoting or propagating discriminatory content or harmful stereotypes.
48
+ - Impersonating individuals without their consent.
49
+ - Sexual content without consent of the people who might see it.
50
+ - Mis- and disinformation
51
+ - Representations of egregious violence and gore
52
+ - Sharing of copyrighted or licensed material in violation of its terms of use.
53
+ - Sharing content that is an alteration of copyrighted or licensed material in violation of its terms of use.
54
+
55
+ ## Limitations and Bias
56
+
57
+ ### Limitations
58
+
59
+ - The model does not achieve perfect photorealism
60
+ - The model cannot render legible text
61
+ - The model does not perform well on more difficult tasks which involve compositionality, such as rendering an image corresponding to “A red cube on top of a blue sphere”
62
+ - Faces and people in general may not be generated properly.
63
+ - The model was trained mainly with English captions and will not work as well in other languages.
64
+ - The autoencoding part of the model is lossy
65
+ - The model was trained on a large-scale dataset
66
+ [LAION-5B](https://laion.ai/blog/laion-5b/) which contains adult material
67
+ and is not fit for product use without additional safety mechanisms and
68
+ considerations.
69
+
70
+ ### Bias
71
+ While the capabilities of image generation models are impressive, they can also reinforce or exacerbate social biases.
72
+ Stable Diffusion v1 was trained on subsets of [LAION-2B(en)](https://laion.ai/blog/laion-5b/),
73
+ which consists of images that are primarily limited to English descriptions.
74
+ Texts and images from communities and cultures that use other languages are likely to be insufficiently accounted for.
75
+ This affects the overall output of the model, as white and western cultures are often set as the default. Further, the
76
+ ability of the model to generate content with non-English prompts is significantly worse than with English-language prompts.
77
+
78
+
79
+ ## Training
80
+
81
+ **Training Data**
82
+ The model developers used the following dataset for training the model:
83
+
84
+ - LAION-2B (en) and subsets thereof (see next section)
85
+
86
+ **Training Procedure**
87
+ Stable Diffusion v1 is a latent diffusion model which combines an autoencoder with a diffusion model that is trained in the latent space of the autoencoder. During training,
88
+
89
+ - Images are encoded through an encoder, which turns images into latent representations. The autoencoder uses a relative downsampling factor of 8 and maps images of shape H x W x 3 to latents of shape H/f x W/f x 4
90
+ - Text prompts are encoded through a ViT-L/14 text-encoder.
91
+ - The non-pooled output of the text encoder is fed into the UNet backbone of the latent diffusion model via cross-attention.
92
+ - The loss is a reconstruction objective between the noise that was added to the latent and the prediction made by the UNet.
93
+
94
+ We currently provide three checkpoints, `sd-v1-1.ckpt`, `sd-v1-2.ckpt` and `sd-v1-3.ckpt`,
95
+ which were trained as follows,
96
+
97
+ - `sd-v1-1.ckpt`: 237k steps at resolution `256x256` on [laion2B-en](https://huggingface.co/datasets/laion/laion2B-en).
98
+ 194k steps at resolution `512x512` on [laion-high-resolution](https://huggingface.co/datasets/laion/laion-high-resolution) (170M examples from LAION-5B with resolution `>= 1024x1024`).
99
+ - `sd-v1-2.ckpt`: Resumed from `sd-v1-1.ckpt`.
100
+ 515k steps at resolution `512x512` on "laion-improved-aesthetics" (a subset of laion2B-en,
101
+ filtered to images with an original size `>= 512x512`, estimated aesthetics score `> 5.0`, and an estimated watermark probability `< 0.5`. The watermark estimate is from the LAION-5B metadata, the aesthetics score is estimated using an [improved aesthetics estimator](https://github.com/christophschuhmann/improved-aesthetic-predictor)).
102
+ - `sd-v1-3.ckpt`: Resumed from `sd-v1-2.ckpt`. 195k steps at resolution `512x512` on "laion-improved-aesthetics" and 10\% dropping of the text-conditioning to improve [classifier-free guidance sampling](https://arxiv.org/abs/2207.12598).
103
+
104
+
105
+ - **Hardware:** 32 x 8 x A100 GPUs
106
+ - **Optimizer:** AdamW
107
+ - **Gradient Accumulations**: 2
108
+ - **Batch:** 32 x 8 x 2 x 4 = 2048
109
+ - **Learning rate:** warmup to 0.0001 for 10,000 steps and then kept constant
110
+
111
+ ## Evaluation Results
112
+ Evaluations with different classifier-free guidance scales (1.5, 2.0, 3.0, 4.0,
113
+ 5.0, 6.0, 7.0, 8.0) and 50 PLMS sampling
114
+ steps show the relative improvements of the checkpoints:
115
+
116
+ ![pareto](assets/v1-variants-scores.jpg)
117
+
118
+ Evaluated using 50 PLMS steps and 10000 random prompts from the COCO2017 validation set, evaluated at 512x512 resolution. Not optimized for FID scores.
119
+ ## Environmental Impact
120
+
121
+ **Stable Diffusion v1** **Estimated Emissions**
122
+ Based on that information, we estimate the following CO2 emissions using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700). The hardware, runtime, cloud provider, and compute region were utilized to estimate the carbon impact.
123
+
124
+ - **Hardware Type:** A100 PCIe 40GB
125
+ - **Hours used:** 150000
126
+ - **Cloud Provider:** AWS
127
+ - **Compute Region:** US-east
128
+ - **Carbon Emitted (Power consumption x Time x Carbon produced based on location of power grid):** 11250 kg CO2 eq.
129
+ ## Citation
130
+ @InProceedings{Rombach_2022_CVPR,
131
+ author = {Rombach, Robin and Blattmann, Andreas and Lorenz, Dominik and Esser, Patrick and Ommer, Bj\"orn},
132
+ title = {High-Resolution Image Synthesis With Latent Diffusion Models},
133
+ booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
134
+ month = {June},
135
+ year = {2022},
136
+ pages = {10684-10695}
137
+ }
138
+
139
+ *This model card was written by: Robin Rombach and Patrick Esser and is based on the [DALL-E Mini model card](https://huggingface.co/dalle-mini/dalle-mini).*
140
+
app.py ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse, os, sys, glob, re
6
+ from os import path
7
+ import numpy as np
8
+ from PIL import Image, ImageFont, ImageDraw, ImageFilter, ImageOps
9
+ from io import BytesIO
10
+ import mimetypes
11
+ import base64
12
+ import json
13
+ import torch
14
+
15
+ import gradio as gr
16
+
17
+ from model import AppModel
18
+
19
+ DESCRIPTION = '''# text2image New version with Stable Diffusion!
20
+ Note: This application accepts ONLY English as input.
21
+ '''
22
+
23
+ RealESRGAN_dir = 'models/realesrgan'
24
+ mimetypes.init()
25
+ mimetypes.add_type('application/javascript', '.js')
26
+
27
+ def parse_args() -> argparse.Namespace:
28
+ parser = argparse.ArgumentParser()
29
+ parser.add_argument('--share', action='store_true')
30
+ return parser.parse_args()
31
+
32
+ def readTextFile(*args):
33
+ dir = path.dirname(__file__)
34
+ entry = path.join(dir, *args)
35
+ with open(entry, "r", encoding="utf8") as f:
36
+ data = f.read()
37
+ return data
38
+
39
+ def torch_gc():
40
+ torch.cuda.empty_cache()
41
+ torch.cuda.ipc_collect()
42
+
43
+ def js():
44
+ data = readTextFile("js", "index.js")
45
+ data = "(z) => {" + data + "; return z ?? [] }"
46
+ return data
47
+
48
+ def call_JS(sd_method, **kwargs):
49
+ param_str = json.dumps(kwargs)
50
+ return f"async (x) => {{ return await SD.{sd_method}({{ x, ...{param_str} }}) ?? []; }}"
51
+
52
+ def load_RealESRGAN(model_name="RealESRGAN_x4plus", checking=False):
53
+ from basicsr.archs.rrdbnet_arch import RRDBNet
54
+ RealESRGAN_models = {
55
+ 'RealESRGAN_x4plus': RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=4),
56
+ }
57
+ model_path = os.path.join(RealESRGAN_dir, model_name + '.pth')
58
+ if not os.path.isfile(model_path):
59
+ raise Exception(model_name+".pth not found at path "+model_path)
60
+ if checking == True:
61
+ return True
62
+ sys.path.append(os.path.abspath(RealESRGAN_dir))
63
+ from realesrgan import RealESRGANer
64
+
65
+ instance = RealESRGANer(scale=2, model_path=model_path, model=RealESRGAN_models[model_name], pre_pad=0, half=True)
66
+ instance.model.name = model_name
67
+ return instance
68
+
69
+ def copy_img_to_sr(img):
70
+ try:
71
+ image_data = re.sub('^data:image/.+;base64,', '', img)
72
+ processed_image = Image.open(BytesIO(base64.b64decode(image_data)))
73
+ tab_update = gr.update(selected='sr_tab')
74
+ img_update = gr.update(value=processed_image)
75
+ return processed_image, tab_update,
76
+ except IndexError:
77
+ return [None, None]
78
+
79
+ class RealESGAN_warp:
80
+ def __init__(self, model):
81
+ self.model = model
82
+
83
+ def run(self, image):
84
+ assert image is not None, "Input image should not be None!"
85
+ image = image.convert("RGB")
86
+ output, img_mode = self.model.enhance(np.array(image, dtype=np.uint8))
87
+ res = Image.fromarray(output)
88
+ return res
89
+
90
+
91
+ def main():
92
+ args = parse_args()
93
+ model = AppModel()
94
+
95
+ SR_model = RealESGAN_warp(load_RealESRGAN())
96
+
97
+ with gr.Blocks(css='style.css') as demo:
98
+ gr.Markdown(DESCRIPTION)
99
+ with gr.Tabs() as tabs:
100
+ with gr.TabItem('Stable Dissusion Generation!'):
101
+ with gr.Row():
102
+ with gr.Row():
103
+ with gr.Column():
104
+ with gr.Group():
105
+ with gr.Row():
106
+ gr.Markdown('Once generation finished, select one image in Gallery and click \'Sent to SR model\' to adapt super resolution!')
107
+ with gr.Row():
108
+ run_button = gr.Button('Run Generation', variant="primary")
109
+ copy_button = gr.Button('Sent to SR model', variant="primary")
110
+ with gr.Tabs():
111
+ with gr.TabItem('Text Prompt'):
112
+ text = gr.Textbox(value="A fantasy landscape, trending on artstation.",
113
+ lines=6, label='Input Text')
114
+ with gr.TabItem('Image Prompt'):
115
+ init_img = gr.Image(type="pil", label="Initial image here")
116
+ gr.Examples(
117
+ examples = [os.path.join(os.path.dirname(__file__), "assets/stable-samples/img2img/sketch-mountains-input.jpg"),
118
+ os.path.join(os.path.dirname(__file__), "assets/logo.jpeg")],
119
+ inputs = init_img,
120
+ )
121
+ with gr.Column():
122
+ with gr.Group():
123
+ seed = gr.Slider(0,
124
+ 1000,
125
+ step=1,
126
+ value=42,
127
+ label='Seed')
128
+ width = gr.Slider(512,
129
+ 960,
130
+ step=64,
131
+ value=960,
132
+ label='width')
133
+ height = gr.Slider(512,
134
+ 576,
135
+ step=64,
136
+ value=512,
137
+ label='height')
138
+
139
+ scale = gr.Slider(1.0,
140
+ 20.0,
141
+ step=0.5,
142
+ value=7.5,
143
+ label='scale')
144
+ steps = gr.Slider(20,
145
+ 200,
146
+ step=1,
147
+ value=50,
148
+ label='steps')
149
+ num_images = gr.Slider(1,
150
+ 1,
151
+ step=1,
152
+ value=1,
153
+ label='Number of Images')
154
+ strength = gr.Slider(0.0,
155
+ 0.99,
156
+ step=0.01,
157
+ value=0.9,
158
+ label='Weight of Prompt Text')
159
+
160
+
161
+ with gr.Column():
162
+ with gr.Group():
163
+ #translated_text = gr.Textbox(label='Translated Text')
164
+ with gr.Tabs():
165
+ with gr.TabItem('Output (Gallery)'):
166
+ result_gallery = gr.Gallery(labels="Images", elem_id="sd_outputs").style(grid=[2,2])
167
+ with gr.TabItem('Output (Grid View)'):
168
+ result_grid = gr.Image(show_label=False)
169
+
170
+ run_button.click(fn=model.run_with_prompt,
171
+ inputs=[
172
+ seed,
173
+ text,
174
+ num_images,
175
+ width,
176
+ height,
177
+ scale,
178
+ steps,
179
+ strength,
180
+ None if not init_img else init_img,
181
+ ],
182
+ outputs=[
183
+ result_grid,
184
+ result_gallery,
185
+ ])
186
+
187
+ with gr.TabItem('Super Resolution!', id="sr_tab"):
188
+ with gr.Column():
189
+ SR_input_img = gr.Image(type="pil", label="SR input image here", elem_id="sr_input")
190
+ SR_button = gr.Button('Run SR', variant="primary")
191
+ with gr.Column():
192
+ SR_result = gr.Image(show_label=False)
193
+
194
+ SR_button.click(fn=SR_model.run,
195
+ inputs=[
196
+ SR_input_img,
197
+ ],
198
+ outputs=[
199
+ SR_result,
200
+ ])
201
+ copy_button.click(fn=copy_img_to_sr,
202
+ inputs=[result_gallery],
203
+ outputs=[SR_input_img, tabs],
204
+ _js=call_JS("moveImageFromGallery",
205
+ fromId="sd_outputs",
206
+ toId="sr_input")
207
+ )
208
+ load_detector = gr.Number(value=0, label="Load Detector", visible=False)
209
+ load_detector.change(None, None, None, _js=js())
210
+ demo.load(lambda x: 42, inputs=load_detector, outputs=load_detector)
211
+
212
+ demo.launch(
213
+ server_name="0.0.0.0",
214
+ server_port=8080,
215
+ enable_queue=True,
216
+ share=args.share,
217
+ )
218
+
219
+
220
+ if __name__ == '__main__':
221
+ main()
assets/a-painting-of-a-fire.png ADDED
assets/a-photograph-of-a-fire.png ADDED
assets/a-shirt-with-a-fire-printed-on-it.png ADDED
assets/a-shirt-with-the-inscription-'fire'.png ADDED
assets/a-watercolor-painting-of-a-fire.png ADDED
assets/birdhouse.png ADDED
assets/fire.png ADDED
assets/inpainting.png ADDED
assets/logo.jpeg ADDED
assets/modelfigure.png ADDED
assets/rdm-preview.jpg ADDED
assets/reconstruction1.png ADDED
assets/reconstruction2.png ADDED
assets/results.gif ADDED

Git LFS Details

  • SHA256: d0739cc1ece5ba1b9b66a42073786b7ac22b97050d134806f5cce9d6d3d0e0e6
  • Pointer size: 132 Bytes
  • Size of remote file: 9.85 MB
assets/stable-samples/img2img/mountains-1.png ADDED
assets/stable-samples/img2img/mountains-2.png ADDED
assets/stable-samples/img2img/mountains-3.png ADDED
assets/stable-samples/img2img/sketch-mountains-input.jpg ADDED
assets/stable-samples/img2img/upscaling-in.png ADDED

Git LFS Details

  • SHA256: 16e043b62bdfcc5be7d0eca5c747878b78e4e6ffaeb3cd1257568cbc2b5e6f7a
  • Pointer size: 132 Bytes
  • Size of remote file: 1.17 MB
assets/stable-samples/img2img/upscaling-out.png ADDED

Git LFS Details

  • SHA256: c171218814d141f87884672cb00ae07c3ed0e14ce7f7023f2041678e01d93f59
  • Pointer size: 132 Bytes
  • Size of remote file: 1.32 MB
assets/stable-samples/txt2img/000002025.png ADDED
assets/stable-samples/txt2img/000002035.png ADDED
assets/stable-samples/txt2img/merged-0005.png ADDED

Git LFS Details

  • SHA256: a417aadc1d91b91531ca6bbf89840a36f432d8e9382aaa953610bedce22ff76f
  • Pointer size: 132 Bytes
  • Size of remote file: 2.58 MB
assets/stable-samples/txt2img/merged-0006.png ADDED

Git LFS Details

  • SHA256: 1d55ba7d103da275b4612976e93f405fcb593f7e6a6fda31f2e180b41c8e4f59
  • Pointer size: 132 Bytes
  • Size of remote file: 2.64 MB
assets/stable-samples/txt2img/merged-0007.png ADDED

Git LFS Details

  • SHA256: 920ccf908b7fa5073a7c5cd3f4e109b5e66f7e29517ef5462ca55e931d0b5689
  • Pointer size: 132 Bytes
  • Size of remote file: 2.41 MB
assets/the-earth-is-on-fire,-oil-on-canvas.png ADDED
assets/txt2img-convsample.png ADDED
assets/txt2img-preview.png ADDED

Git LFS Details

  • SHA256: 15a3eff624b02579aebb930d6c9318fc89c11c51dd22dcb85266e0403402b68e
  • Pointer size: 132 Bytes
  • Size of remote file: 2.26 MB
assets/v1-variants-scores.jpg ADDED
configs/autoencoder/autoencoder_kl_16x16x16.yaml ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ base_learning_rate: 4.5e-6
3
+ target: ldm.models.autoencoder.AutoencoderKL
4
+ params:
5
+ monitor: "val/rec_loss"
6
+ embed_dim: 16
7
+ lossconfig:
8
+ target: ldm.modules.losses.LPIPSWithDiscriminator
9
+ params:
10
+ disc_start: 50001
11
+ kl_weight: 0.000001
12
+ disc_weight: 0.5
13
+
14
+ ddconfig:
15
+ double_z: True
16
+ z_channels: 16
17
+ resolution: 256
18
+ in_channels: 3
19
+ out_ch: 3
20
+ ch: 128
21
+ ch_mult: [ 1,1,2,2,4] # num_down = len(ch_mult)-1
22
+ num_res_blocks: 2
23
+ attn_resolutions: [16]
24
+ dropout: 0.0
25
+
26
+
27
+ data:
28
+ target: main.DataModuleFromConfig
29
+ params:
30
+ batch_size: 12
31
+ wrap: True
32
+ train:
33
+ target: ldm.data.imagenet.ImageNetSRTrain
34
+ params:
35
+ size: 256
36
+ degradation: pil_nearest
37
+ validation:
38
+ target: ldm.data.imagenet.ImageNetSRValidation
39
+ params:
40
+ size: 256
41
+ degradation: pil_nearest
42
+
43
+ lightning:
44
+ callbacks:
45
+ image_logger:
46
+ target: main.ImageLogger
47
+ params:
48
+ batch_frequency: 1000
49
+ max_images: 8
50
+ increase_log_steps: True
51
+
52
+ trainer:
53
+ benchmark: True
54
+ accumulate_grad_batches: 2
configs/autoencoder/autoencoder_kl_32x32x4.yaml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ base_learning_rate: 4.5e-6
3
+ target: ldm.models.autoencoder.AutoencoderKL
4
+ params:
5
+ monitor: "val/rec_loss"
6
+ embed_dim: 4
7
+ lossconfig:
8
+ target: ldm.modules.losses.LPIPSWithDiscriminator
9
+ params:
10
+ disc_start: 50001
11
+ kl_weight: 0.000001
12
+ disc_weight: 0.5
13
+
14
+ ddconfig:
15
+ double_z: True
16
+ z_channels: 4
17
+ resolution: 256
18
+ in_channels: 3
19
+ out_ch: 3
20
+ ch: 128
21
+ ch_mult: [ 1,2,4,4 ] # num_down = len(ch_mult)-1
22
+ num_res_blocks: 2
23
+ attn_resolutions: [ ]
24
+ dropout: 0.0
25
+
26
+ data:
27
+ target: main.DataModuleFromConfig
28
+ params:
29
+ batch_size: 12
30
+ wrap: True
31
+ train:
32
+ target: ldm.data.imagenet.ImageNetSRTrain
33
+ params:
34
+ size: 256
35
+ degradation: pil_nearest
36
+ validation:
37
+ target: ldm.data.imagenet.ImageNetSRValidation
38
+ params:
39
+ size: 256
40
+ degradation: pil_nearest
41
+
42
+ lightning:
43
+ callbacks:
44
+ image_logger:
45
+ target: main.ImageLogger
46
+ params:
47
+ batch_frequency: 1000
48
+ max_images: 8
49
+ increase_log_steps: True
50
+
51
+ trainer:
52
+ benchmark: True
53
+ accumulate_grad_batches: 2
configs/autoencoder/autoencoder_kl_64x64x3.yaml ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ base_learning_rate: 4.5e-6
3
+ target: ldm.models.autoencoder.AutoencoderKL
4
+ params:
5
+ monitor: "val/rec_loss"
6
+ embed_dim: 3
7
+ lossconfig:
8
+ target: ldm.modules.losses.LPIPSWithDiscriminator
9
+ params:
10
+ disc_start: 50001
11
+ kl_weight: 0.000001
12
+ disc_weight: 0.5
13
+
14
+ ddconfig:
15
+ double_z: True
16
+ z_channels: 3
17
+ resolution: 256
18
+ in_channels: 3
19
+ out_ch: 3
20
+ ch: 128
21
+ ch_mult: [ 1,2,4 ] # num_down = len(ch_mult)-1
22
+ num_res_blocks: 2
23
+ attn_resolutions: [ ]
24
+ dropout: 0.0
25
+
26
+
27
+ data:
28
+ target: main.DataModuleFromConfig
29
+ params:
30
+ batch_size: 12
31
+ wrap: True
32
+ train:
33
+ target: ldm.data.imagenet.ImageNetSRTrain
34
+ params:
35
+ size: 256
36
+ degradation: pil_nearest
37
+ validation:
38
+ target: ldm.data.imagenet.ImageNetSRValidation
39
+ params:
40
+ size: 256
41
+ degradation: pil_nearest
42
+
43
+ lightning:
44
+ callbacks:
45
+ image_logger:
46
+ target: main.ImageLogger
47
+ params:
48
+ batch_frequency: 1000
49
+ max_images: 8
50
+ increase_log_steps: True
51
+
52
+ trainer:
53
+ benchmark: True
54
+ accumulate_grad_batches: 2
configs/autoencoder/autoencoder_kl_8x8x64.yaml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ base_learning_rate: 4.5e-6
3
+ target: ldm.models.autoencoder.AutoencoderKL
4
+ params:
5
+ monitor: "val/rec_loss"
6
+ embed_dim: 64
7
+ lossconfig:
8
+ target: ldm.modules.losses.LPIPSWithDiscriminator
9
+ params:
10
+ disc_start: 50001
11
+ kl_weight: 0.000001
12
+ disc_weight: 0.5
13
+
14
+ ddconfig:
15
+ double_z: True
16
+ z_channels: 64
17
+ resolution: 256
18
+ in_channels: 3
19
+ out_ch: 3
20
+ ch: 128
21
+ ch_mult: [ 1,1,2,2,4,4] # num_down = len(ch_mult)-1
22
+ num_res_blocks: 2
23
+ attn_resolutions: [16,8]
24
+ dropout: 0.0
25
+
26
+ data:
27
+ target: main.DataModuleFromConfig
28
+ params:
29
+ batch_size: 12
30
+ wrap: True
31
+ train:
32
+ target: ldm.data.imagenet.ImageNetSRTrain
33
+ params:
34
+ size: 256
35
+ degradation: pil_nearest
36
+ validation:
37
+ target: ldm.data.imagenet.ImageNetSRValidation
38
+ params:
39
+ size: 256
40
+ degradation: pil_nearest
41
+
42
+ lightning:
43
+ callbacks:
44
+ image_logger:
45
+ target: main.ImageLogger
46
+ params:
47
+ batch_frequency: 1000
48
+ max_images: 8
49
+ increase_log_steps: True
50
+
51
+ trainer:
52
+ benchmark: True
53
+ accumulate_grad_batches: 2
configs/latent-diffusion/celebahq-ldm-vq-4.yaml ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ base_learning_rate: 2.0e-06
3
+ target: ldm.models.diffusion.ddpm.LatentDiffusion
4
+ params:
5
+ linear_start: 0.0015
6
+ linear_end: 0.0195
7
+ num_timesteps_cond: 1
8
+ log_every_t: 200
9
+ timesteps: 1000
10
+ first_stage_key: image
11
+ image_size: 64
12
+ channels: 3
13
+ monitor: val/loss_simple_ema
14
+
15
+ unet_config:
16
+ target: ldm.modules.diffusionmodules.openaimodel.UNetModel
17
+ params:
18
+ image_size: 64
19
+ in_channels: 3
20
+ out_channels: 3
21
+ model_channels: 224
22
+ attention_resolutions:
23
+ # note: this isn\t actually the resolution but
24
+ # the downsampling factor, i.e. this corresnponds to
25
+ # attention on spatial resolution 8,16,32, as the
26
+ # spatial reolution of the latents is 64 for f4
27
+ - 8
28
+ - 4
29
+ - 2
30
+ num_res_blocks: 2
31
+ channel_mult:
32
+ - 1
33
+ - 2
34
+ - 3
35
+ - 4
36
+ num_head_channels: 32
37
+ first_stage_config:
38
+ target: ldm.models.autoencoder.VQModelInterface
39
+ params:
40
+ embed_dim: 3
41
+ n_embed: 8192
42
+ ckpt_path: models/first_stage_models/vq-f4/model.ckpt
43
+ ddconfig:
44
+ double_z: false
45
+ z_channels: 3
46
+ resolution: 256
47
+ in_channels: 3
48
+ out_ch: 3
49
+ ch: 128
50
+ ch_mult:
51
+ - 1
52
+ - 2
53
+ - 4
54
+ num_res_blocks: 2
55
+ attn_resolutions: []
56
+ dropout: 0.0
57
+ lossconfig:
58
+ target: torch.nn.Identity
59
+ cond_stage_config: __is_unconditional__
60
+ data:
61
+ target: main.DataModuleFromConfig
62
+ params:
63
+ batch_size: 48
64
+ num_workers: 5
65
+ wrap: false
66
+ train:
67
+ target: taming.data.faceshq.CelebAHQTrain
68
+ params:
69
+ size: 256
70
+ validation:
71
+ target: taming.data.faceshq.CelebAHQValidation
72
+ params:
73
+ size: 256
74
+
75
+
76
+ lightning:
77
+ callbacks:
78
+ image_logger:
79
+ target: main.ImageLogger
80
+ params:
81
+ batch_frequency: 5000
82
+ max_images: 8
83
+ increase_log_steps: False
84
+
85
+ trainer:
86
+ benchmark: True
configs/latent-diffusion/cin-ldm-vq-f8.yaml ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ base_learning_rate: 1.0e-06
3
+ target: ldm.models.diffusion.ddpm.LatentDiffusion
4
+ params:
5
+ linear_start: 0.0015
6
+ linear_end: 0.0195
7
+ num_timesteps_cond: 1
8
+ log_every_t: 200
9
+ timesteps: 1000
10
+ first_stage_key: image
11
+ cond_stage_key: class_label
12
+ image_size: 32
13
+ channels: 4
14
+ cond_stage_trainable: true
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ unet_config:
18
+ target: ldm.modules.diffusionmodules.openaimodel.UNetModel
19
+ params:
20
+ image_size: 32
21
+ in_channels: 4
22
+ out_channels: 4
23
+ model_channels: 256
24
+ attention_resolutions:
25
+ #note: this isn\t actually the resolution but
26
+ # the downsampling factor, i.e. this corresnponds to
27
+ # attention on spatial resolution 8,16,32, as the
28
+ # spatial reolution of the latents is 32 for f8
29
+ - 4
30
+ - 2
31
+ - 1
32
+ num_res_blocks: 2
33
+ channel_mult:
34
+ - 1
35
+ - 2
36
+ - 4
37
+ num_head_channels: 32
38
+ use_spatial_transformer: true
39
+ transformer_depth: 1
40
+ context_dim: 512
41
+ first_stage_config:
42
+ target: ldm.models.autoencoder.VQModelInterface
43
+ params:
44
+ embed_dim: 4
45
+ n_embed: 16384
46
+ ckpt_path: configs/first_stage_models/vq-f8/model.yaml
47
+ ddconfig:
48
+ double_z: false
49
+ z_channels: 4
50
+ resolution: 256
51
+ in_channels: 3
52
+ out_ch: 3
53
+ ch: 128
54
+ ch_mult:
55
+ - 1
56
+ - 2
57
+ - 2
58
+ - 4
59
+ num_res_blocks: 2
60
+ attn_resolutions:
61
+ - 32
62
+ dropout: 0.0
63
+ lossconfig:
64
+ target: torch.nn.Identity
65
+ cond_stage_config:
66
+ target: ldm.modules.encoders.modules.ClassEmbedder
67
+ params:
68
+ embed_dim: 512
69
+ key: class_label
70
+ data:
71
+ target: main.DataModuleFromConfig
72
+ params:
73
+ batch_size: 64
74
+ num_workers: 12
75
+ wrap: false
76
+ train:
77
+ target: ldm.data.imagenet.ImageNetTrain
78
+ params:
79
+ config:
80
+ size: 256
81
+ validation:
82
+ target: ldm.data.imagenet.ImageNetValidation
83
+ params:
84
+ config:
85
+ size: 256
86
+
87
+
88
+ lightning:
89
+ callbacks:
90
+ image_logger:
91
+ target: main.ImageLogger
92
+ params:
93
+ batch_frequency: 5000
94
+ max_images: 8
95
+ increase_log_steps: False
96
+
97
+ trainer:
98
+ benchmark: True
configs/latent-diffusion/cin256-v2.yaml ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ base_learning_rate: 0.0001
3
+ target: ldm.models.diffusion.ddpm.LatentDiffusion
4
+ params:
5
+ linear_start: 0.0015
6
+ linear_end: 0.0195
7
+ num_timesteps_cond: 1
8
+ log_every_t: 200
9
+ timesteps: 1000
10
+ first_stage_key: image
11
+ cond_stage_key: class_label
12
+ image_size: 64
13
+ channels: 3
14
+ cond_stage_trainable: true
15
+ conditioning_key: crossattn
16
+ monitor: val/loss
17
+ use_ema: False
18
+
19
+ unet_config:
20
+ target: ldm.modules.diffusionmodules.openaimodel.UNetModel
21
+ params:
22
+ image_size: 64
23
+ in_channels: 3
24
+ out_channels: 3
25
+ model_channels: 192
26
+ attention_resolutions:
27
+ - 8
28
+ - 4
29
+ - 2
30
+ num_res_blocks: 2
31
+ channel_mult:
32
+ - 1
33
+ - 2
34
+ - 3
35
+ - 5
36
+ num_heads: 1
37
+ use_spatial_transformer: true
38
+ transformer_depth: 1
39
+ context_dim: 512
40
+
41
+ first_stage_config:
42
+ target: ldm.models.autoencoder.VQModelInterface
43
+ params:
44
+ embed_dim: 3
45
+ n_embed: 8192
46
+ ddconfig:
47
+ double_z: false
48
+ z_channels: 3
49
+ resolution: 256
50
+ in_channels: 3
51
+ out_ch: 3
52
+ ch: 128
53
+ ch_mult:
54
+ - 1
55
+ - 2
56
+ - 4
57
+ num_res_blocks: 2
58
+ attn_resolutions: []
59
+ dropout: 0.0
60
+ lossconfig:
61
+ target: torch.nn.Identity
62
+
63
+ cond_stage_config:
64
+ target: ldm.modules.encoders.modules.ClassEmbedder
65
+ params:
66
+ n_classes: 1001
67
+ embed_dim: 512
68
+ key: class_label
configs/latent-diffusion/ffhq-ldm-vq-4.yaml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ base_learning_rate: 2.0e-06
3
+ target: ldm.models.diffusion.ddpm.LatentDiffusion
4
+ params:
5
+ linear_start: 0.0015
6
+ linear_end: 0.0195
7
+ num_timesteps_cond: 1
8
+ log_every_t: 200
9
+ timesteps: 1000
10
+ first_stage_key: image
11
+ image_size: 64
12
+ channels: 3
13
+ monitor: val/loss_simple_ema
14
+ unet_config:
15
+ target: ldm.modules.diffusionmodules.openaimodel.UNetModel
16
+ params:
17
+ image_size: 64
18
+ in_channels: 3
19
+ out_channels: 3
20
+ model_channels: 224
21
+ attention_resolutions:
22
+ # note: this isn\t actually the resolution but
23
+ # the downsampling factor, i.e. this corresnponds to
24
+ # attention on spatial resolution 8,16,32, as the
25
+ # spatial reolution of the latents is 64 for f4
26
+ - 8
27
+ - 4
28
+ - 2
29
+ num_res_blocks: 2
30
+ channel_mult:
31
+ - 1
32
+ - 2
33
+ - 3
34
+ - 4
35
+ num_head_channels: 32
36
+ first_stage_config:
37
+ target: ldm.models.autoencoder.VQModelInterface
38
+ params:
39
+ embed_dim: 3
40
+ n_embed: 8192
41
+ ckpt_path: configs/first_stage_models/vq-f4/model.yaml
42
+ ddconfig:
43
+ double_z: false
44
+ z_channels: 3
45
+ resolution: 256
46
+ in_channels: 3
47
+ out_ch: 3
48
+ ch: 128
49
+ ch_mult:
50
+ - 1
51
+ - 2
52
+ - 4
53
+ num_res_blocks: 2
54
+ attn_resolutions: []
55
+ dropout: 0.0
56
+ lossconfig:
57
+ target: torch.nn.Identity
58
+ cond_stage_config: __is_unconditional__
59
+ data:
60
+ target: main.DataModuleFromConfig
61
+ params:
62
+ batch_size: 42
63
+ num_workers: 5
64
+ wrap: false
65
+ train:
66
+ target: taming.data.faceshq.FFHQTrain
67
+ params:
68
+ size: 256
69
+ validation:
70
+ target: taming.data.faceshq.FFHQValidation
71
+ params:
72
+ size: 256
73
+
74
+
75
+ lightning:
76
+ callbacks:
77
+ image_logger:
78
+ target: main.ImageLogger
79
+ params:
80
+ batch_frequency: 5000
81
+ max_images: 8
82
+ increase_log_steps: False
83
+
84
+ trainer:
85
+ benchmark: True
configs/latent-diffusion/lsun_bedrooms-ldm-vq-4.yaml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ base_learning_rate: 2.0e-06
3
+ target: ldm.models.diffusion.ddpm.LatentDiffusion
4
+ params:
5
+ linear_start: 0.0015
6
+ linear_end: 0.0195
7
+ num_timesteps_cond: 1
8
+ log_every_t: 200
9
+ timesteps: 1000
10
+ first_stage_key: image
11
+ image_size: 64
12
+ channels: 3
13
+ monitor: val/loss_simple_ema
14
+ unet_config:
15
+ target: ldm.modules.diffusionmodules.openaimodel.UNetModel
16
+ params:
17
+ image_size: 64
18
+ in_channels: 3
19
+ out_channels: 3
20
+ model_channels: 224
21
+ attention_resolutions:
22
+ # note: this isn\t actually the resolution but
23
+ # the downsampling factor, i.e. this corresnponds to
24
+ # attention on spatial resolution 8,16,32, as the
25
+ # spatial reolution of the latents is 64 for f4
26
+ - 8
27
+ - 4
28
+ - 2
29
+ num_res_blocks: 2
30
+ channel_mult:
31
+ - 1
32
+ - 2
33
+ - 3
34
+ - 4
35
+ num_head_channels: 32
36
+ first_stage_config:
37
+ target: ldm.models.autoencoder.VQModelInterface
38
+ params:
39
+ ckpt_path: configs/first_stage_models/vq-f4/model.yaml
40
+ embed_dim: 3
41
+ n_embed: 8192
42
+ ddconfig:
43
+ double_z: false
44
+ z_channels: 3
45
+ resolution: 256
46
+ in_channels: 3
47
+ out_ch: 3
48
+ ch: 128
49
+ ch_mult:
50
+ - 1
51
+ - 2
52
+ - 4
53
+ num_res_blocks: 2
54
+ attn_resolutions: []
55
+ dropout: 0.0
56
+ lossconfig:
57
+ target: torch.nn.Identity
58
+ cond_stage_config: __is_unconditional__
59
+ data:
60
+ target: main.DataModuleFromConfig
61
+ params:
62
+ batch_size: 48
63
+ num_workers: 5
64
+ wrap: false
65
+ train:
66
+ target: ldm.data.lsun.LSUNBedroomsTrain
67
+ params:
68
+ size: 256
69
+ validation:
70
+ target: ldm.data.lsun.LSUNBedroomsValidation
71
+ params:
72
+ size: 256
73
+
74
+
75
+ lightning:
76
+ callbacks:
77
+ image_logger:
78
+ target: main.ImageLogger
79
+ params:
80
+ batch_frequency: 5000
81
+ max_images: 8
82
+ increase_log_steps: False
83
+
84
+ trainer:
85
+ benchmark: True
configs/latent-diffusion/lsun_churches-ldm-kl-8.yaml ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ base_learning_rate: 5.0e-5 # set to target_lr by starting main.py with '--scale_lr False'
3
+ target: ldm.models.diffusion.ddpm.LatentDiffusion
4
+ params:
5
+ linear_start: 0.0015
6
+ linear_end: 0.0155
7
+ num_timesteps_cond: 1
8
+ log_every_t: 200
9
+ timesteps: 1000
10
+ loss_type: l1
11
+ first_stage_key: "image"
12
+ cond_stage_key: "image"
13
+ image_size: 32
14
+ channels: 4
15
+ cond_stage_trainable: False
16
+ concat_mode: False
17
+ scale_by_std: True
18
+ monitor: 'val/loss_simple_ema'
19
+
20
+ scheduler_config: # 10000 warmup steps
21
+ target: ldm.lr_scheduler.LambdaLinearScheduler
22
+ params:
23
+ warm_up_steps: [10000]
24
+ cycle_lengths: [10000000000000]
25
+ f_start: [1.e-6]
26
+ f_max: [1.]
27
+ f_min: [ 1.]
28
+
29
+ unet_config:
30
+ target: ldm.modules.diffusionmodules.openaimodel.UNetModel
31
+ params:
32
+ image_size: 32
33
+ in_channels: 4
34
+ out_channels: 4
35
+ model_channels: 192
36
+ attention_resolutions: [ 1, 2, 4, 8 ] # 32, 16, 8, 4
37
+ num_res_blocks: 2
38
+ channel_mult: [ 1,2,2,4,4 ] # 32, 16, 8, 4, 2
39
+ num_heads: 8
40
+ use_scale_shift_norm: True
41
+ resblock_updown: True
42
+
43
+ first_stage_config:
44
+ target: ldm.models.autoencoder.AutoencoderKL
45
+ params:
46
+ embed_dim: 4
47
+ monitor: "val/rec_loss"
48
+ ckpt_path: "models/first_stage_models/kl-f8/model.ckpt"
49
+ ddconfig:
50
+ double_z: True
51
+ z_channels: 4
52
+ resolution: 256
53
+ in_channels: 3
54
+ out_ch: 3
55
+ ch: 128
56
+ ch_mult: [ 1,2,4,4 ] # num_down = len(ch_mult)-1
57
+ num_res_blocks: 2
58
+ attn_resolutions: [ ]
59
+ dropout: 0.0
60
+ lossconfig:
61
+ target: torch.nn.Identity
62
+
63
+ cond_stage_config: "__is_unconditional__"
64
+
65
+ data:
66
+ target: main.DataModuleFromConfig
67
+ params:
68
+ batch_size: 96
69
+ num_workers: 5
70
+ wrap: False
71
+ train:
72
+ target: ldm.data.lsun.LSUNChurchesTrain
73
+ params:
74
+ size: 256
75
+ validation:
76
+ target: ldm.data.lsun.LSUNChurchesValidation
77
+ params:
78
+ size: 256
79
+
80
+ lightning:
81
+ callbacks:
82
+ image_logger:
83
+ target: main.ImageLogger
84
+ params:
85
+ batch_frequency: 5000
86
+ max_images: 8
87
+ increase_log_steps: False
88
+
89
+
90
+ trainer:
91
+ benchmark: True
configs/latent-diffusion/txt2img-1p4B-eval.yaml ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ base_learning_rate: 5.0e-05
3
+ target: ldm.models.diffusion.ddpm.LatentDiffusion
4
+ params:
5
+ linear_start: 0.00085
6
+ linear_end: 0.012
7
+ num_timesteps_cond: 1
8
+ log_every_t: 200
9
+ timesteps: 1000
10
+ first_stage_key: image
11
+ cond_stage_key: caption
12
+ image_size: 32
13
+ channels: 4
14
+ cond_stage_trainable: true
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+
20
+ unet_config:
21
+ target: ldm.modules.diffusionmodules.openaimodel.UNetModel
22
+ params:
23
+ image_size: 32
24
+ in_channels: 4
25
+ out_channels: 4
26
+ model_channels: 320
27
+ attention_resolutions:
28
+ - 4
29
+ - 2
30
+ - 1
31
+ num_res_blocks: 2
32
+ channel_mult:
33
+ - 1
34
+ - 2
35
+ - 4
36
+ - 4
37
+ num_heads: 8
38
+ use_spatial_transformer: true
39
+ transformer_depth: 1
40
+ context_dim: 1280
41
+ use_checkpoint: true
42
+ legacy: False
43
+
44
+ first_stage_config:
45
+ target: ldm.models.autoencoder.AutoencoderKL
46
+ params:
47
+ embed_dim: 4
48
+ monitor: val/rec_loss
49
+ ddconfig:
50
+ double_z: true
51
+ z_channels: 4
52
+ resolution: 256
53
+ in_channels: 3
54
+ out_ch: 3
55
+ ch: 128
56
+ ch_mult:
57
+ - 1
58
+ - 2
59
+ - 4
60
+ - 4
61
+ num_res_blocks: 2
62
+ attn_resolutions: []
63
+ dropout: 0.0
64
+ lossconfig:
65
+ target: torch.nn.Identity
66
+
67
+ cond_stage_config:
68
+ target: ldm.modules.encoders.modules.BERTEmbedder
69
+ params:
70
+ n_embed: 1280
71
+ n_layer: 32
configs/retrieval-augmented-diffusion/768x768.yaml ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ base_learning_rate: 0.0001
3
+ target: ldm.models.diffusion.ddpm.LatentDiffusion
4
+ params:
5
+ linear_start: 0.0015
6
+ linear_end: 0.015
7
+ num_timesteps_cond: 1
8
+ log_every_t: 200
9
+ timesteps: 1000
10
+ first_stage_key: jpg
11
+ cond_stage_key: nix
12
+ image_size: 48
13
+ channels: 16
14
+ cond_stage_trainable: false
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_by_std: false
18
+ scale_factor: 0.22765929
19
+ unet_config:
20
+ target: ldm.modules.diffusionmodules.openaimodel.UNetModel
21
+ params:
22
+ image_size: 48
23
+ in_channels: 16
24
+ out_channels: 16
25
+ model_channels: 448
26
+ attention_resolutions:
27
+ - 4
28
+ - 2
29
+ - 1
30
+ num_res_blocks: 2
31
+ channel_mult:
32
+ - 1
33
+ - 2
34
+ - 3
35
+ - 4
36
+ use_scale_shift_norm: false
37
+ resblock_updown: false
38
+ num_head_channels: 32
39
+ use_spatial_transformer: true
40
+ transformer_depth: 1
41
+ context_dim: 768
42
+ use_checkpoint: true
43
+ first_stage_config:
44
+ target: ldm.models.autoencoder.AutoencoderKL
45
+ params:
46
+ monitor: val/rec_loss
47
+ embed_dim: 16
48
+ ddconfig:
49
+ double_z: true
50
+ z_channels: 16
51
+ resolution: 256
52
+ in_channels: 3
53
+ out_ch: 3
54
+ ch: 128
55
+ ch_mult:
56
+ - 1
57
+ - 1
58
+ - 2
59
+ - 2
60
+ - 4
61
+ num_res_blocks: 2
62
+ attn_resolutions:
63
+ - 16
64
+ dropout: 0.0
65
+ lossconfig:
66
+ target: torch.nn.Identity
67
+ cond_stage_config:
68
+ target: torch.nn.Identity
configs/stable-diffusion/v1-inference.yaml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ base_learning_rate: 1.0e-04
3
+ target: ldm.models.diffusion.ddpm.LatentDiffusion
4
+ params:
5
+ linear_start: 0.00085
6
+ linear_end: 0.0120
7
+ num_timesteps_cond: 1
8
+ log_every_t: 200
9
+ timesteps: 1000
10
+ first_stage_key: "jpg"
11
+ cond_stage_key: "txt"
12
+ image_size: 64
13
+ channels: 4
14
+ cond_stage_trainable: false # Note: different from the one we trained before
15
+ conditioning_key: crossattn
16
+ monitor: val/loss_simple_ema
17
+ scale_factor: 0.18215
18
+ use_ema: False
19
+
20
+ scheduler_config: # 10000 warmup steps
21
+ target: ldm.lr_scheduler.LambdaLinearScheduler
22
+ params:
23
+ warm_up_steps: [ 10000 ]
24
+ cycle_lengths: [ 10000000000000 ] # incredibly large number to prevent corner cases
25
+ f_start: [ 1.e-6 ]
26
+ f_max: [ 1. ]
27
+ f_min: [ 1. ]
28
+
29
+ unet_config:
30
+ target: ldm.modules.diffusionmodules.openaimodel.UNetModel
31
+ params:
32
+ image_size: 32 # unused
33
+ in_channels: 4
34
+ out_channels: 4
35
+ model_channels: 320
36
+ attention_resolutions: [ 4, 2, 1 ]
37
+ num_res_blocks: 2
38
+ channel_mult: [ 1, 2, 4, 4 ]
39
+ num_heads: 8
40
+ use_spatial_transformer: True
41
+ transformer_depth: 1
42
+ context_dim: 768
43
+ use_checkpoint: True
44
+ legacy: False
45
+
46
+ first_stage_config:
47
+ target: ldm.models.autoencoder.AutoencoderKL
48
+ params:
49
+ embed_dim: 4
50
+ monitor: val/rec_loss
51
+ ddconfig:
52
+ double_z: true
53
+ z_channels: 4
54
+ resolution: 256
55
+ in_channels: 3
56
+ out_ch: 3
57
+ ch: 128
58
+ ch_mult:
59
+ - 1
60
+ - 2
61
+ - 4
62
+ - 4
63
+ num_res_blocks: 2
64
+ attn_resolutions: []
65
+ dropout: 0.0
66
+ lossconfig:
67
+ target: torch.nn.Identity
68
+
69
+ cond_stage_config:
70
+ target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
data/DejaVuSans.ttf ADDED
Binary file (757 kB). View file
 
data/example_conditioning/superresolution/sample_0.jpg ADDED