radames HF staff commited on
Commit
e3ce2d3
1 Parent(s): a510503

using latest diffusers

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitignore +2 -1
  2. app.py +109 -6
  3. {stablediffusion/examples → examples}/baby.jpg +0 -0
  4. {stablediffusion/examples → examples}/gol.jpg +0 -0
  5. requirements.txt +2 -24
  6. stablediffusion/LICENSE +0 -21
  7. stablediffusion/LICENSE-MODEL +0 -84
  8. stablediffusion/README.md +0 -245
  9. stablediffusion/assets/model-variants.jpg +0 -0
  10. stablediffusion/assets/modelfigure.png +0 -3
  11. stablediffusion/assets/rick.jpeg +0 -0
  12. stablediffusion/assets/stable-inpainting/inpainting.gif +0 -3
  13. stablediffusion/assets/stable-inpainting/merged-leopards.png +0 -3
  14. stablediffusion/assets/stable-samples/depth2img/d2i.gif +0 -3
  15. stablediffusion/assets/stable-samples/depth2img/depth2fantasy.jpeg +0 -0
  16. stablediffusion/assets/stable-samples/depth2img/depth2img01.png +0 -3
  17. stablediffusion/assets/stable-samples/depth2img/depth2img02.png +0 -3
  18. stablediffusion/assets/stable-samples/depth2img/merged-0000.png +0 -3
  19. stablediffusion/assets/stable-samples/depth2img/merged-0004.png +0 -3
  20. stablediffusion/assets/stable-samples/depth2img/merged-0005.png +0 -3
  21. stablediffusion/assets/stable-samples/depth2img/midas.jpeg +0 -0
  22. stablediffusion/assets/stable-samples/depth2img/old_man.png +0 -3
  23. stablediffusion/assets/stable-samples/img2img/mountains-1.png +0 -3
  24. stablediffusion/assets/stable-samples/img2img/mountains-2.png +0 -3
  25. stablediffusion/assets/stable-samples/img2img/mountains-3.png +0 -3
  26. stablediffusion/assets/stable-samples/img2img/sketch-mountains-input.jpg +0 -0
  27. stablediffusion/assets/stable-samples/img2img/upscaling-in.png +0 -3
  28. stablediffusion/assets/stable-samples/img2img/upscaling-out.png +0 -3
  29. stablediffusion/assets/stable-samples/txt2img/000002025.png +0 -3
  30. stablediffusion/assets/stable-samples/txt2img/000002035.png +0 -3
  31. stablediffusion/assets/stable-samples/txt2img/768/merged-0001.png +0 -3
  32. stablediffusion/assets/stable-samples/txt2img/768/merged-0002.png +0 -3
  33. stablediffusion/assets/stable-samples/txt2img/768/merged-0003.png +0 -3
  34. stablediffusion/assets/stable-samples/txt2img/768/merged-0004.png +0 -3
  35. stablediffusion/assets/stable-samples/txt2img/768/merged-0005.png +0 -3
  36. stablediffusion/assets/stable-samples/txt2img/768/merged-0006.png +0 -3
  37. stablediffusion/assets/stable-samples/txt2img/merged-0001.png +0 -3
  38. stablediffusion/assets/stable-samples/txt2img/merged-0003.png +0 -3
  39. stablediffusion/assets/stable-samples/txt2img/merged-0005.png +0 -3
  40. stablediffusion/assets/stable-samples/txt2img/merged-0006.png +0 -3
  41. stablediffusion/assets/stable-samples/txt2img/merged-0007.png +0 -3
  42. stablediffusion/assets/stable-samples/upscaling/merged-dog.png +0 -3
  43. stablediffusion/assets/stable-samples/upscaling/sampled-bear-x4.png +0 -3
  44. stablediffusion/assets/stable-samples/upscaling/snow-leopard-x4.png +0 -3
  45. stablediffusion/configs/stable-diffusion/v2-inference-v.yaml +0 -68
  46. stablediffusion/configs/stable-diffusion/v2-inference.yaml +0 -67
  47. stablediffusion/configs/stable-diffusion/v2-inpainting-inference.yaml +0 -158
  48. stablediffusion/configs/stable-diffusion/v2-midas-inference.yaml +0 -74
  49. stablediffusion/configs/stable-diffusion/x4-upscaling.yaml +0 -76
  50. stablediffusion/environment.yaml +0 -29
.gitignore CHANGED
@@ -1,4 +1,5 @@
1
  **/midas_models/
2
  stable-diffusion-2-depth/
3
  __pycache__
4
- gradio_cached_examples
 
1
  **/midas_models/
2
  stable-diffusion-2-depth/
3
  __pycache__
4
+ gradio_cached_examples
5
+ venv/
app.py CHANGED
@@ -1,6 +1,109 @@
1
- from os import system
2
- system('git clone https://huggingface.co/stabilityai/stable-diffusion-2-depth && cd stable-diffusion-2-depth && git lfs fetch && git lfs pull')
3
- system('pip install -e stablediffusion')
4
- system('curl -LJ https://github.com/isl-org/DPT/releases/download/1_0/dpt_hybrid-midas-501f0c75.pt --create-dirs -o stablediffusion/midas_models/dpt_hybrid-midas-501f0c75.pt')
5
- system('curl -LJ https://github.com/isl-org/DPT/releases/download/1_0/dpt_large-midas-2f21e586.pt --create-dirs -o stablediffusion/midas_models/dpt_large-midas-2f21e586.pt')
6
- system('cd stablediffusion && python scripts/gradio/depth2img.py configs/stable-diffusion/v2-midas-inference.yaml ../stable-diffusion-2-depth/512-depth-ema.ckpt')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from PIL import Image
4
+ import numpy as np
5
+ from diffusers import StableDiffusionDepth2ImgPipeline
6
+ from pathlib import Path
7
+
8
+ dept2img = StableDiffusionDepth2ImgPipeline.from_pretrained(
9
+ "stabilityai/stable-diffusion-2-depth",
10
+ torch_dtype=torch.float16,
11
+ ).to("cuda")
12
+
13
+
14
+ def pad_image(input_image):
15
+ pad_w, pad_h = np.max(((2, 2), np.ceil(
16
+ np.array(input_image.size) / 64).astype(int)), axis=0) * 64 - input_image.size
17
+ im_padded = Image.fromarray(
18
+ np.pad(np.array(input_image), ((0, pad_h), (0, pad_w), (0, 0)), mode='edge'))
19
+ w, h = im_padded.size
20
+ if w == h:
21
+ return im_padded
22
+ elif w > h:
23
+ new_image = Image.new(im_padded.mode, (w, w), (0, 0, 0))
24
+ new_image.paste(im_padded, (0, (w - h) // 2))
25
+ return new_image
26
+ else:
27
+ new_image = Image.new(im_padded.mode, (h, h), (0, 0, 0))
28
+ new_image.paste(im_padded, ((h - w) // 2, 0))
29
+ return new_image
30
+
31
+
32
+ def predict(input_image, prompt, negative_prompt, steps, num_samples, scale, seed, strength, depth_image=None):
33
+ depth = None
34
+ if depth_image is not None:
35
+ depth_image = pad_image(depth_image)
36
+ depth = np.array(depth_image.convert("L"))
37
+ depth = depth.astype(np.float32) / 255.0
38
+ depth = depth[None, None]
39
+ depth = torch.from_numpy(depth)
40
+ init_image = input_image.convert("RGB")
41
+ image = pad_image(init_image) # resize to integer multiple of 32
42
+ image = image.resize((512, 512))
43
+ result = dept2img(
44
+ image=image,
45
+ prompt=prompt,
46
+ negative_prompt=negative_prompt,
47
+ depth_image=depth,
48
+ seed=seed,
49
+ strength=strength,
50
+ num_inference_steps=steps,
51
+ guidance_scale=scale,
52
+ num_images_per_prompt=num_samples,
53
+ )
54
+ return result['images']
55
+
56
+
57
+ block = gr.Blocks().queue()
58
+ with block:
59
+ with gr.Row():
60
+ gr.Markdown("## Stable Diffusion 2 Depth2Img")
61
+
62
+ with gr.Row():
63
+ with gr.Column():
64
+ input_image = gr.Image(source='upload', type="pil")
65
+ depth_image = gr.Image(
66
+ source='upload', type="pil", label="Depth image Optional", value=None)
67
+ prompt = gr.Textbox(label="Prompt")
68
+ negative_prompt = gr.Textbox(label="Negative Pompt")
69
+
70
+ run_button = gr.Button(label="Run")
71
+ with gr.Accordion("Advanced options", open=False):
72
+ num_samples = gr.Slider(
73
+ label="Images", minimum=1, maximum=4, value=1, step=1)
74
+ steps = gr.Slider(label="Steps", minimum=1,
75
+ maximum=50, value=50, step=1)
76
+ scale = gr.Slider(
77
+ label="Guidance Scale", minimum=0.1, maximum=30.0, value=9.0, step=0.1
78
+ )
79
+ strength = gr.Slider(
80
+ label="Strength", minimum=0.0, maximum=1.0, value=0.9, step=0.01
81
+ )
82
+ seed = gr.Slider(
83
+ label="Seed",
84
+ minimum=0,
85
+ maximum=2147483647,
86
+ step=1,
87
+ randomize=True,
88
+ )
89
+ with gr.Column():
90
+ gallery = gr.Gallery(label="Generated images", show_label=False).style(
91
+ grid=[2], height="auto")
92
+ gr.Examples(
93
+ examples=[
94
+ ["./examples/baby.jpg", "high definition photo of a baby astronaut space walking at the international space station with earth seeing from above in the background",
95
+ "", 50, 4, 9.0, 123123123, 0.8, None],
96
+ ["./examples/gol.jpg", "professional photo of a Elmo jumping between two high rises, beautiful colorful city landscape in the background",
97
+ "", 50, 4, 9.0, 1734133747, 0.9, None]
98
+ ],
99
+ inputs=[input_image, prompt, negative_prompt, steps,
100
+ num_samples, scale, seed, strength, depth_image],
101
+ outputs=[gallery],
102
+ fn=predict,
103
+ cache_examples=True,
104
+ )
105
+ run_button.click(fn=predict, inputs=[input_image, prompt, negative_prompt,
106
+ steps, num_samples, scale, seed, strength, depth_image], outputs=[gallery])
107
+
108
+
109
+ block.launch(show_api=False)
{stablediffusion/examples → examples}/baby.jpg RENAMED
File without changes
{stablediffusion/examples → examples}/gol.jpg RENAMED
File without changes
requirements.txt CHANGED
@@ -1,26 +1,4 @@
1
  gradio
2
  --extra-index-url https://download.pytorch.org/whl/cu113
3
- torch
4
- torchvision
5
- numpy
6
- python-dotenv
7
- invisible-watermark
8
- timm
9
- opencv-python
10
- pudb==2019.2
11
- imageio==2.9.0
12
- imageio-ffmpeg==0.4.2
13
- pytorch-lightning==1.4.2
14
- torchmetrics==0.6
15
- omegaconf==2.1.1
16
- test-tube>=0.7.5
17
- einops==0.3.0
18
- transformers==4.19.2
19
- webdataset==0.2.5
20
-
21
- albumentations==1.3.0
22
- streamlit==1.12.1
23
- kornia==0.6
24
- open_clip_torch==2.0.2
25
- streamlit-drawable-canvas==0.8.0
26
- # -e ./stablediffusion
1
  gradio
2
  --extra-index-url https://download.pytorch.org/whl/cu113
3
+ diffusers[torch]
4
+ git+https://github.com/huggingface/transformers@main
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
stablediffusion/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Stability AI
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
stablediffusion/LICENSE-MODEL DELETED
@@ -1,84 +0,0 @@
1
- Copyright (c) 2022 Stability AI and contributors
2
-
3
- CreativeML Open RAIL++-M License
4
- dated November 24, 2022
5
-
6
- Section I: PREAMBLE
7
-
8
- Multimodal generative models are being widely adopted and used, and have the potential to transform the way artists, among other individuals, conceive and benefit from AI or ML technologies as a tool for content creation.
9
-
10
- Notwithstanding the current and potential benefits that these artifacts can bring to society at large, there are also concerns about potential misuses of them, either due to their technical limitations or ethical considerations.
11
-
12
- In short, this license strives for both the open and responsible downstream use of the accompanying model. When it comes to the open character, we took inspiration from open source permissive licenses regarding the grant of IP rights. Referring to the downstream responsible use, we added use-based restrictions not permitting the use of the Model in very specific scenarios, in order for the licensor to be able to enforce the license in case potential misuses of the Model may occur. At the same time, we strive to promote open and responsible research on generative models for art and content generation.
13
-
14
- Even though downstream derivative versions of the model could be released under different licensing terms, the latter will always have to include - at minimum - the same use-based restrictions as the ones in the original license (this license). We believe in the intersection between open and responsible AI development; thus, this License aims to strike a balance between both in order to enable responsible open-science in the field of AI.
15
-
16
- This License governs the use of the model (and its derivatives) and is informed by the model card associated with the model.
17
-
18
- NOW THEREFORE, You and Licensor agree as follows:
19
-
20
- 1. Definitions
21
-
22
- - "License" means the terms and conditions for use, reproduction, and Distribution as defined in this document.
23
- - "Data" means a collection of information and/or content extracted from the dataset used with the Model, including to train, pretrain, or otherwise evaluate the Model. The Data is not licensed under this License.
24
- - "Output" means the results of operating a Model as embodied in informational content resulting therefrom.
25
- - "Model" means any accompanying machine-learning based assemblies (including checkpoints), consisting of learnt weights, parameters (including optimizer states), corresponding to the model architecture as embodied in the Complementary Material, that have been trained or tuned, in whole or in part on the Data, using the Complementary Material.
26
- - "Derivatives of the Model" means all modifications to the Model, works based on the Model, or any other model which is created or initialized by transfer of patterns of the weights, parameters, activations or output of the Model, to the other model, in order to cause the other model to perform similarly to the Model, including - but not limited to - distillation methods entailing the use of intermediate data representations or methods based on the generation of synthetic data by the Model for training the other model.
27
- - "Complementary Material" means the accompanying source code and scripts used to define, run, load, benchmark or evaluate the Model, and used to prepare data for training or evaluation, if any. This includes any accompanying documentation, tutorials, examples, etc, if any.
28
- - "Distribution" means any transmission, reproduction, publication or other sharing of the Model or Derivatives of the Model to a third party, including providing the Model as a hosted service made available by electronic or other remote means - e.g. API-based or web access.
29
- - "Licensor" means the copyright owner or entity authorized by the copyright owner that is granting the License, including the persons or entities that may have rights in the Model and/or distributing the Model.
30
- - "You" (or "Your") means an individual or Legal Entity exercising permissions granted by this License and/or making use of the Model for whichever purpose and in any field of use, including usage of the Model in an end-use application - e.g. chatbot, translator, image generator.
31
- - "Third Parties" means individuals or legal entities that are not under common control with Licensor or You.
32
- - "Contribution" means any work of authorship, including the original version of the Model and any modifications or additions to that Model or Derivatives of the Model thereof, that is intentionally submitted to Licensor for inclusion in the Model by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Model, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
33
- - "Contributor" means Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Model.
34
-
35
- Section II: INTELLECTUAL PROPERTY RIGHTS
36
-
37
- Both copyright and patent grants apply to the Model, Derivatives of the Model and Complementary Material. The Model and Derivatives of the Model are subject to additional terms as described in Section III.
38
-
39
- 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare, publicly display, publicly perform, sublicense, and distribute the Complementary Material, the Model, and Derivatives of the Model.
40
- 3. Grant of Patent License. Subject to the terms and conditions of this License and where and as applicable, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this paragraph) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Model and the Complementary Material, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Model to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Model and/or Complementary Material or a Contribution incorporated within the Model and/or Complementary Material constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for the Model and/or Work shall terminate as of the date such litigation is asserted or filed.
41
-
42
- Section III: CONDITIONS OF USAGE, DISTRIBUTION AND REDISTRIBUTION
43
-
44
- 4. Distribution and Redistribution. You may host for Third Party remote access purposes (e.g. software-as-a-service), reproduce and distribute copies of the Model or Derivatives of the Model thereof in any medium, with or without modifications, provided that You meet the following conditions:
45
- Use-based restrictions as referenced in paragraph 5 MUST be included as an enforceable provision by You in any type of legal agreement (e.g. a license) governing the use and/or distribution of the Model or Derivatives of the Model, and You shall give notice to subsequent users You Distribute to, that the Model or Derivatives of the Model are subject to paragraph 5. This provision does not apply to the use of Complementary Material.
46
- You must give any Third Party recipients of the Model or Derivatives of the Model a copy of this License;
47
- You must cause any modified files to carry prominent notices stating that You changed the files;
48
- You must retain all copyright, patent, trademark, and attribution notices excluding those notices that do not pertain to any part of the Model, Derivatives of the Model.
49
- You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions - respecting paragraph 4.a. - for use, reproduction, or Distribution of Your modifications, or for any such Derivatives of the Model as a whole, provided Your use, reproduction, and Distribution of the Model otherwise complies with the conditions stated in this License.
50
- 5. Use-based restrictions. The restrictions set forth in Attachment A are considered Use-based restrictions. Therefore You cannot use the Model and the Derivatives of the Model for the specified restricted uses. You may use the Model subject to this License, including only for lawful purposes and in accordance with the License. Use may include creating any content with, finetuning, updating, running, training, evaluating and/or reparametrizing the Model. You shall require all of Your users who use the Model or a Derivative of the Model to comply with the terms of this paragraph (paragraph 5).
51
- 6. The Output You Generate. Except as set forth herein, Licensor claims no rights in the Output You generate using the Model. You are accountable for the Output you generate and its subsequent uses. No use of the output can contravene any provision as stated in the License.
52
-
53
- Section IV: OTHER PROVISIONS
54
-
55
- 7. Updates and Runtime Restrictions. To the maximum extent permitted by law, Licensor reserves the right to restrict (remotely or otherwise) usage of the Model in violation of this License.
56
- 8. Trademarks and related. Nothing in this License permits You to make use of Licensors’ trademarks, trade names, logos or to otherwise suggest endorsement or misrepresent the relationship between the parties; and any rights not expressly granted herein are reserved by the Licensors.
57
- 9. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Model and the Complementary Material (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Model, Derivatives of the Model, and the Complementary Material and assume any risks associated with Your exercise of permissions under this License.
58
- 10. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Model and the Complementary Material (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
59
- 11. Accepting Warranty or Additional Liability. While redistributing the Model, Derivatives of the Model and the Complementary Material thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
60
- 12. If any provision of this License is held to be invalid, illegal or unenforceable, the remaining provisions shall be unaffected thereby and remain valid as if such provision had not been set forth herein.
61
-
62
- END OF TERMS AND CONDITIONS
63
-
64
-
65
-
66
-
67
- Attachment A
68
-
69
- Use Restrictions
70
-
71
- You agree not to use the Model or Derivatives of the Model:
72
-
73
- - In any way that violates any applicable national, federal, state, local or international law or regulation;
74
- - For the purpose of exploiting, harming or attempting to exploit or harm minors in any way;
75
- - To generate or disseminate verifiably false information and/or content with the purpose of harming others;
76
- - To generate or disseminate personal identifiable information that can be used to harm an individual;
77
- - To defame, disparage or otherwise harass others;
78
- - For fully automated decision making that adversely impacts an individual’s legal rights or otherwise creates or modifies a binding, enforceable obligation;
79
- - For any use intended to or which has the effect of discriminating against or harming individuals or groups based on online or offline social behavior or known or predicted personal or personality characteristics;
80
- - To exploit any of the vulnerabilities of a specific group of persons based on their age, social, physical or mental characteristics, in order to materially distort the behavior of a person pertaining to that group in a manner that causes or is likely to cause that person or another person physical or psychological harm;
81
- - For any use intended to or which has the effect of discriminating against individuals or groups based on legally protected characteristics or categories;
82
- - To provide medical advice and medical results interpretation;
83
- - To generate or disseminate information for the purpose to be used for administration of justice, law enforcement, immigration or asylum processes, such as predicting an individual will commit fraud/crime commitment (e.g. by text profiling, drawing causal relationships between assertions made in documents, indiscriminate and arbitrarily-targeted use).
84
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
stablediffusion/README.md DELETED
@@ -1,245 +0,0 @@
1
- # Stable Diffusion 2.0
2
- ![t2i](assets/stable-samples/txt2img/768/merged-0006.png)
3
- ![t2i](assets/stable-samples/txt2img/768/merged-0002.png)
4
- ![t2i](assets/stable-samples/txt2img/768/merged-0005.png)
5
-
6
- This repository contains [Stable Diffusion](https://github.com/CompVis/stable-diffusion) models trained from scratch and will be continuously updated with
7
- new checkpoints. The following list provides an overview of all currently available models. More coming soon.
8
- ## News
9
- **November 2022**
10
- - New stable diffusion model (_Stable Diffusion 2.0-v_) at 768x768 resolution. Same number of parameters in the U-Net as 1.5, but uses [OpenCLIP-ViT/H](https://github.com/mlfoundations/open_clip) as the text encoder and is trained from scratch. _SD 2.0-v_ is a so-called [v-prediction](https://arxiv.org/abs/2202.00512) model.
11
- - The above model is finetuned from _SD 2.0-base_, which was trained as a standard noise-prediction model on 512x512 images and is also made available.
12
- - Added a [x4 upscaling latent text-guided diffusion model](#image-upscaling-with-stable-diffusion).
13
- - New [depth-guided stable diffusion model](#depth-conditional-stable-diffusion), finetuned from _SD 2.0-base_. The model is conditioned on monocular depth estimates inferred via [MiDaS](https://github.com/isl-org/MiDaS) and can be used for structure-preserving img2img and shape-conditional synthesis.
14
-
15
- ![d2i](assets/stable-samples/depth2img/depth2img01.png)
16
- - A [text-guided inpainting model](#image-inpainting-with-stable-diffusion), finetuned from SD _2.0-base_.
17
-
18
- We follow the [original repository](https://github.com/CompVis/stable-diffusion) and provide basic inference scripts to sample from the models.
19
-
20
- ________________
21
- *The original Stable Diffusion model was created in a collaboration with [CompVis](https://arxiv.org/abs/2202.00512) and [RunwayML](https://runwayml.com/) and builds upon the work:*
22
-
23
- [**High-Resolution Image Synthesis with Latent Diffusion Models**](https://ommer-lab.com/research/latent-diffusion-models/)<br/>
24
- [Robin Rombach](https://github.com/rromb)\*,
25
- [Andreas Blattmann](https://github.com/ablattmann)\*,
26
- [Dominik Lorenz](https://github.com/qp-qp)\,
27
- [Patrick Esser](https://github.com/pesser),
28
- [Björn Ommer](https://hci.iwr.uni-heidelberg.de/Staff/bommer)<br/>
29
- _[CVPR '22 Oral](https://openaccess.thecvf.com/content/CVPR2022/html/Rombach_High-Resolution_Image_Synthesis_With_Latent_Diffusion_Models_CVPR_2022_paper.html) |
30
- [GitHub](https://github.com/CompVis/latent-diffusion) | [arXiv](https://arxiv.org/abs/2112.10752) | [Project page](https://ommer-lab.com/research/latent-diffusion-models/)_
31
-
32
- and [many others](#shout-outs).
33
-
34
- Stable Diffusion is a latent text-to-image diffusion model.
35
- ________________________________
36
-
37
- ## Requirements
38
-
39
- You can update an existing [latent diffusion](https://github.com/CompVis/latent-diffusion) environment by running
40
-
41
- ```
42
- conda install pytorch==1.12.1 torchvision==0.13.1 -c pytorch
43
- pip install transformers==4.19.2 diffusers invisible-watermark
44
- pip install -e .
45
- ```
46
- #### xformers efficient attention
47
- For more efficiency and speed on GPUs,
48
- we highly recommended installing the [xformers](https://github.com/facebookresearch/xformers)
49
- library.
50
-
51
- Tested on A100 with CUDA 11.4.
52
- Installation needs a somewhat recent version of nvcc and gcc/g++, obtain those, e.g., via
53
- ```commandline
54
- export CUDA_HOME=/usr/local/cuda-11.4
55
- conda install -c nvidia/label/cuda-11.4.0 cuda-nvcc
56
- conda install -c conda-forge gcc
57
- conda install -c conda-forge gxx_linux-64=9.5.0
58
- ```
59
-
60
- Then, run the following (compiling takes up to 30 min).
61
-
62
- ```commandline
63
- cd ..
64
- git clone https://github.com/facebookresearch/xformers.git
65
- cd xformers
66
- git submodule update --init --recursive
67
- pip install -r requirements.txt
68
- pip install -e .
69
- cd ../stablediffusion
70
- ```
71
- Upon successful installation, the code will automatically default to [memory efficient attention](https://github.com/facebookresearch/xformers)
72
- for the self- and cross-attention layers in the U-Net and autoencoder.
73
-
74
- ## General Disclaimer
75
- Stable Diffusion models are general text-to-image diffusion models and therefore mirror biases and (mis-)conceptions that are present
76
- in their training data. Although efforts were made to reduce the inclusion of explicit pornographic material, **we do not recommend using the provided weights for services or products without additional safety mechanisms and considerations.
77
- The weights are research artifacts and should be treated as such.**
78
- 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/stabilityai/stable-diffusion-2).
79
- The weights are available via [the StabilityAI organization at Hugging Face](https://huggingface.co/StabilityAI) under the [CreativeML Open RAIL++-M License](LICENSE-MODEL).
80
-
81
-
82
-
83
- ## Stable Diffusion v2.0
84
-
85
- Stable Diffusion v2.0 refers to a specific configuration of the model
86
- architecture that uses a downsampling-factor 8 autoencoder with an 865M UNet
87
- and OpenCLIP ViT-H/14 text encoder for the diffusion model. The _SD 2.0-v_ model produces 768x768 px outputs.
88
-
89
- Evaluations with different classifier-free guidance scales (1.5, 2.0, 3.0, 4.0,
90
- 5.0, 6.0, 7.0, 8.0) and 50 DDIM sampling steps show the relative improvements of the checkpoints:
91
-
92
- ![sd evaluation results](assets/model-variants.jpg)
93
-
94
-
95
-
96
- ### Text-to-Image
97
- ![txt2img-stable2](assets/stable-samples/txt2img/merged-0003.png)
98
- ![txt2img-stable2](assets/stable-samples/txt2img/merged-0001.png)
99
-
100
- Stable Diffusion 2.0 is a latent diffusion model conditioned on the penultimate text embeddings of a CLIP ViT-H/14 text encoder.
101
- We provide a [reference script for sampling](#reference-sampling-script).
102
- #### Reference Sampling Script
103
-
104
- This script incorporates an [invisible watermarking](https://github.com/ShieldMnt/invisible-watermark) of the outputs, to help viewers [identify the images as machine-generated](scripts/tests/test_watermark.py).
105
- We provide the configs for the _SD2.0-v_ (768px) and _SD2.0-base_ (512px) model.
106
-
107
- First, download the weights for [_SD2.0-v_](https://huggingface.co/stabilityai/stable-diffusion-2) and [_SD2.0-base_](https://huggingface.co/stabilityai/stable-diffusion-2-base).
108
-
109
- To sample from the _SD2.0-v_ model, run the following:
110
-
111
- ```
112
- python scripts/txt2img.py --prompt "a professional photograph of an astronaut riding a horse" --ckpt <path/to/768model.ckpt/> --config configs/stable-diffusion/v2-inference-v.yaml --H 768 --W 768
113
- ```
114
- or try out the Web Demo: [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/stabilityai/stable-diffusion).
115
-
116
- To sample from the base model, use
117
- ```
118
- python scripts/txt2img.py --prompt "a professional photograph of an astronaut riding a horse" --ckpt <path/to/model.ckpt/> --config <path/to/config.yaml/>
119
- ```
120
-
121
- By default, this uses the [DDIM sampler](https://arxiv.org/abs/2010.02502), and renders images of size 768x768 (which it was trained on) in 50 steps.
122
- Empirically, the v-models can be sampled with higher guidance scales.
123
-
124
- Note: The inference config for all model versions is designed to be used with EMA-only checkpoints.
125
- For this reason `use_ema=False` is set in the configuration, otherwise the code will try to switch from
126
- non-EMA to EMA weights.
127
-
128
- ### Image Modification with Stable Diffusion
129
-
130
- ![depth2img-stable2](assets/stable-samples/depth2img/merged-0000.png)
131
- #### Depth-Conditional Stable Diffusion
132
-
133
- To augment the well-established [img2img](https://github.com/CompVis/stable-diffusion#image-modification-with-stable-diffusion) functionality of Stable Diffusion, we provide a _shape-preserving_ stable diffusion model.
134
-
135
-
136
- Note that the original method for image modification introduces significant semantic changes w.r.t. the initial image.
137
- If that is not desired, download our [depth-conditional stable diffusion](https://huggingface.co/stabilityai/stable-diffusion-2-depth) model and the `dpt_hybrid` MiDaS [model weights](https://github.com/intel-isl/DPT/releases/download/1_0/dpt_hybrid-midas-501f0c75.pt), place the latter in a folder `midas_models` and sample via
138
- ```
139
- python scripts/gradio/depth2img.py configs/stable-diffusion/v2-midas-inference.yaml <path-to-ckpt>
140
- ```
141
-
142
- or
143
-
144
- ```
145
- streamlit run scripts/streamlit/depth2img.py configs/stable-diffusion/v2-midas-inference.yaml <path-to-ckpt>
146
- ```
147
-
148
- This method can be used on the samples of the base model itself.
149
- For example, take [this sample](assets/stable-samples/depth2img/old_man.png) generated by an anonymous discord user.
150
- Using the [gradio](https://gradio.app) or [streamlit](https://streamlit.io/) script `depth2img.py`, the MiDaS model first infers a monocular depth estimate given this input,
151
- and the diffusion model is then conditioned on the (relative) depth output.
152
-
153
- <p align="center">
154
- <b> depth2image </b><br/>
155
- <img src=assets/stable-samples/depth2img/d2i.gif/>
156
- </p>
157
-
158
- This model is particularly useful for a photorealistic style; see the [examples](assets/stable-samples/depth2img).
159
- For a maximum strength of 1.0, the model removes all pixel-based information and only relies on the text prompt and the inferred monocular depth estimate.
160
-
161
- ![depth2img-stable3](assets/stable-samples/depth2img/merged-0005.png)
162
-
163
- #### Classic Img2Img
164
-
165
- For running the "classic" img2img, use
166
- ```
167
- python scripts/img2img.py --prompt "A fantasy landscape, trending on artstation" --init-img <path-to-img.jpg> --strength 0.8 --ckpt <path/to/model.ckpt>
168
- ```
169
- and adapt the checkpoint and config paths accordingly.
170
-
171
- ### Image Upscaling with Stable Diffusion
172
- ![upscaling-x4](assets/stable-samples/upscaling/merged-dog.png)
173
- After [downloading the weights](https://huggingface.co/stabilityai/stable-diffusion-x4-upscaler), run
174
- ```
175
- python scripts/gradio/superresolution.py configs/stable-diffusion/x4-upscaling.yaml <path-to-checkpoint>
176
- ```
177
-
178
- or
179
-
180
- ```
181
- streamlit run scripts/streamlit/superresolution.py -- configs/stable-diffusion/x4-upscaling.yaml <path-to-checkpoint>
182
- ```
183
-
184
- for a Gradio or Streamlit demo of the text-guided x4 superresolution model.
185
- This model can be used both on real inputs and on synthesized examples. For the latter, we recommend setting a higher
186
- `noise_level`, e.g. `noise_level=100`.
187
-
188
- ### Image Inpainting with Stable Diffusion
189
-
190
- ![inpainting-stable2](assets/stable-inpainting/merged-leopards.png)
191
-
192
- [Download the SD 2.0-inpainting checkpoint](https://huggingface.co/stabilityai/stable-diffusion-2-inpainting) and run
193
-
194
- ```
195
- python scripts/gradio/inpainting.py configs/stable-diffusion/v2-inpainting-inference.yaml <path-to-checkpoint>
196
- ```
197
-
198
- or
199
-
200
- ```
201
- streamlit run scripts/streamlit/inpainting.py -- configs/stable-diffusion/v2-inpainting-inference.yaml <path-to-checkpoint>
202
- ```
203
-
204
- for a Gradio or Streamlit demo of the inpainting model.
205
- This scripts adds invisible watermarking to the demo in the [RunwayML](https://github.com/runwayml/stable-diffusion/blob/main/scripts/inpaint_st.py) repository, but both should work interchangeably with the checkpoints/configs.
206
-
207
-
208
-
209
- ## Shout-Outs
210
- - Thanks to [Hugging Face](https://huggingface.co/) and in particular [Apolinário](https://github.com/apolinario) for support with our model releases!
211
- - Stable Diffusion would not be possible without [LAION](https://laion.ai/) and their efforts to create open, large-scale datasets.
212
- - The [DeepFloyd team](https://twitter.com/deepfloydai) at Stability AI, for creating the subset of [LAION-5B](https://laion.ai/blog/laion-5b/) dataset used to train the model.
213
- - Stable Diffusion 2.0 uses [OpenCLIP](https://laion.ai/blog/large-openclip/), trained by [Romain Beaumont](https://github.com/rom1504).
214
- - Our codebase for the diffusion models builds heavily on [OpenAI's ADM codebase](https://github.com/openai/guided-diffusion)
215
- and [https://github.com/lucidrains/denoising-diffusion-pytorch](https://github.com/lucidrains/denoising-diffusion-pytorch).
216
- Thanks for open-sourcing!
217
- - [CompVis](https://github.com/CompVis/stable-diffusion) initial stable diffusion release
218
- - [Patrick](https://github.com/pesser)'s [implementation](https://github.com/runwayml/stable-diffusion/blob/main/scripts/inpaint_st.py) of the streamlit demo for inpainting.
219
- - `img2img` is an application of [SDEdit](https://arxiv.org/abs/2108.01073) by [Chenlin Meng](https://cs.stanford.edu/~chenlin/) from the [Stanford AI Lab](https://cs.stanford.edu/~ermon/website/).
220
- - [Kat's implementation]((https://github.com/CompVis/latent-diffusion/pull/51)) of the [PLMS](https://arxiv.org/abs/2202.09778) sampler, and [more](https://github.com/crowsonkb/k-diffusion).
221
- - [DPMSolver](https://arxiv.org/abs/2206.00927) [integration](https://github.com/CompVis/stable-diffusion/pull/440) by [Cheng Lu](https://github.com/LuChengTHU).
222
- - Facebook's [xformers](https://github.com/facebookresearch/xformers) for efficient attention computation.
223
- - [MiDaS](https://github.com/isl-org/MiDaS) for monocular depth estimation.
224
-
225
-
226
- ## License
227
-
228
- The code in this repository is released under the MIT License.
229
-
230
- The weights are available via [the StabilityAI organization at Hugging Face](https://huggingface.co/StabilityAI), and released under the [CreativeML Open RAIL++-M License](LICENSE-MODEL) License.
231
-
232
- ## BibTeX
233
-
234
- ```
235
- @misc{rombach2021highresolution,
236
- title={High-Resolution Image Synthesis with Latent Diffusion Models},
237
- author={Robin Rombach and Andreas Blattmann and Dominik Lorenz and Patrick Esser and Björn Ommer},
238
- year={2021},
239
- eprint={2112.10752},
240
- archivePrefix={arXiv},
241
- primaryClass={cs.CV}
242
- }
243
- ```
244
-
245
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
stablediffusion/assets/model-variants.jpg DELETED
Binary file (76.5 kB)
stablediffusion/assets/modelfigure.png DELETED

Git LFS Details

  • SHA256: a59d205fae97f2e32edcc99b960401d4655094f7fb35fefc236c13e99c5e5a3d
  • Pointer size: 130 Bytes
  • Size of remote file: 73.8 kB
stablediffusion/assets/rick.jpeg DELETED
Binary file (232 kB)
stablediffusion/assets/stable-inpainting/inpainting.gif DELETED

Git LFS Details

  • SHA256: 7b2558147098eab73921dc597fd8ee8c958eb280a0e3761412868d4cc271ccc4
  • Pointer size: 131 Bytes
  • Size of remote file: 886 kB
stablediffusion/assets/stable-inpainting/merged-leopards.png DELETED

Git LFS Details

  • SHA256: 94a05d717a340d7b240283e72e91984e82093750ba066aa05ab0759188467e69
  • Pointer size: 132 Bytes
  • Size of remote file: 4.96 MB
stablediffusion/assets/stable-samples/depth2img/d2i.gif DELETED

Git LFS Details

  • SHA256: 7236fc7f4349740c537ef9c8730590c15d198aaf42925a46755ded26bc436bc4
  • Pointer size: 132 Bytes
  • Size of remote file: 1.14 MB
stablediffusion/assets/stable-samples/depth2img/depth2fantasy.jpeg DELETED
Binary file (260 kB)
stablediffusion/assets/stable-samples/depth2img/depth2img01.png DELETED

Git LFS Details

  • SHA256: 60cb68c273602eae8e2fb769a2848e55844d812196260ada112a9aecc604f735
  • Pointer size: 132 Bytes
  • Size of remote file: 3.32 MB
stablediffusion/assets/stable-samples/depth2img/depth2img02.png DELETED

Git LFS Details

  • SHA256: adabff92594b17a2554408257d2ab61eb9b89270d5917eafd44a9b75740aab04
  • Pointer size: 132 Bytes
  • Size of remote file: 1.78 MB
stablediffusion/assets/stable-samples/depth2img/merged-0000.png DELETED

Git LFS Details

  • SHA256: b19da6052f01a3b115ac3315ef5db1b7dcdb58091879c0dfe3895a7765a491ac
  • Pointer size: 132 Bytes
  • Size of remote file: 2.13 MB
stablediffusion/assets/stable-samples/depth2img/merged-0004.png DELETED

Git LFS Details

  • SHA256: 0d3ae25218f696375aa953e55d12d034da3bd7abce68616a3af916bdae01cc86
  • Pointer size: 132 Bytes
  • Size of remote file: 1.45 MB
stablediffusion/assets/stable-samples/depth2img/merged-0005.png DELETED

Git LFS Details

  • SHA256: 935252e202a3a6cafa476443f3a0ae3ac95cf85c37c0133f4f32af2aafb8f9ab
  • Pointer size: 132 Bytes
  • Size of remote file: 4.55 MB
stablediffusion/assets/stable-samples/depth2img/midas.jpeg DELETED
Binary file (40.3 kB)
stablediffusion/assets/stable-samples/depth2img/old_man.png DELETED

Git LFS Details

  • SHA256: 4ba6e75e7f24f69839a586c895b2cbcc6559a52eaac3d915078b1232e9956d9b
  • Pointer size: 131 Bytes
  • Size of remote file: 554 kB
stablediffusion/assets/stable-samples/img2img/mountains-1.png DELETED

Git LFS Details

  • SHA256: db02e9545f40d083f5202c4ce7ab948273a5399e5032cc0f7ed037b7e3fcfa93
  • Pointer size: 131 Bytes
  • Size of remote file: 625 kB
stablediffusion/assets/stable-samples/img2img/mountains-2.png DELETED

Git LFS Details

  • SHA256: ffcfe5095f1bd7e2cc244f8ea55a03b45610942699d6b52aefbdce57054d1642
  • Pointer size: 131 Bytes
  • Size of remote file: 658 kB
stablediffusion/assets/stable-samples/img2img/mountains-3.png DELETED

Git LFS Details

  • SHA256: 2b08c5eb8790bb06369c56635b57115e97b032af657b53a571e16c4438c7261a
  • Pointer size: 131 Bytes
  • Size of remote file: 656 kB
stablediffusion/assets/stable-samples/img2img/sketch-mountains-input.jpg DELETED
Binary file (179 kB)
stablediffusion/assets/stable-samples/img2img/upscaling-in.png DELETED

Git LFS Details

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

Git LFS Details

  • SHA256: c171218814d141f87884672cb00ae07c3ed0e14ce7f7023f2041678e01d93f59
  • Pointer size: 132 Bytes
  • Size of remote file: 1.32 MB
stablediffusion/assets/stable-samples/txt2img/000002025.png DELETED

Git LFS Details

  • SHA256: 427e10286097e0334a7721d9d61aed74a7386fcca97a3d49d8a41fbe93ecbb72
  • Pointer size: 131 Bytes
  • Size of remote file: 968 kB
stablediffusion/assets/stable-samples/txt2img/000002035.png DELETED

Git LFS Details

  • SHA256: 8a72b7473d8c95252df70e84e9ed214e6c61ceacf07864783d9d08a2abd9bc6a
  • Pointer size: 131 Bytes
  • Size of remote file: 996 kB
stablediffusion/assets/stable-samples/txt2img/768/merged-0001.png DELETED

Git LFS Details

  • SHA256: ed10e1df0f4c0f83794310e59a77098b4836d96a2b12cc809ddf39e77b1b6c94
  • Pointer size: 132 Bytes
  • Size of remote file: 4.63 MB
stablediffusion/assets/stable-samples/txt2img/768/merged-0002.png DELETED

Git LFS Details

  • SHA256: b4a009d112633ac788fbbe7a7176d4002e95407b64672afa8104755534bb4641
  • Pointer size: 132 Bytes
  • Size of remote file: 3.46 MB
stablediffusion/assets/stable-samples/txt2img/768/merged-0003.png DELETED

Git LFS Details

  • SHA256: 84adec03ab2e2d54990950a113af97750eab90135596461689efe5ebfa1ebf92
  • Pointer size: 132 Bytes
  • Size of remote file: 3.83 MB
stablediffusion/assets/stable-samples/txt2img/768/merged-0004.png DELETED

Git LFS Details

  • SHA256: 8ac938c03b4b554e1c475a4b3c5df50b72a890eec21542fa7911a8ff01bf13f4
  • Pointer size: 132 Bytes
  • Size of remote file: 4.1 MB
stablediffusion/assets/stable-samples/txt2img/768/merged-0005.png DELETED

Git LFS Details

  • SHA256: 849b877a80752b4578afc2ece4ea0726768809298ee9a38284ba4e159d0a817c
  • Pointer size: 132 Bytes
  • Size of remote file: 2.17 MB
stablediffusion/assets/stable-samples/txt2img/768/merged-0006.png DELETED

Git LFS Details

  • SHA256: 2d31dbbf76633677be3b8eba933e9eec82825925535ef9c557a3003daf16ad42
  • Pointer size: 132 Bytes
  • Size of remote file: 4.37 MB
stablediffusion/assets/stable-samples/txt2img/merged-0001.png DELETED

Git LFS Details

  • SHA256: 71ca5f77befffa10a2ef6d4b69f8bb721e7ebd7ea03538e2c359dc44f526b0e8
  • Pointer size: 132 Bytes
  • Size of remote file: 2.41 MB
stablediffusion/assets/stable-samples/txt2img/merged-0003.png DELETED

Git LFS Details

  • SHA256: 9fde5a40c512d61e2390e70d9f14b0d33f0af84cbde2dcd9d86e1f9b38072266
  • Pointer size: 132 Bytes
  • Size of remote file: 2.27 MB
stablediffusion/assets/stable-samples/txt2img/merged-0005.png DELETED

Git LFS Details

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

Git LFS Details

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

Git LFS Details

  • SHA256: 920ccf908b7fa5073a7c5cd3f4e109b5e66f7e29517ef5462ca55e931d0b5689
  • Pointer size: 132 Bytes
  • Size of remote file: 2.41 MB
stablediffusion/assets/stable-samples/upscaling/merged-dog.png DELETED

Git LFS Details

  • SHA256: d85d15bd51b3fa162f2b020ccac5a64b10ced728c6f22dcba183dc65ab6e8b5a
  • Pointer size: 132 Bytes
  • Size of remote file: 1.82 MB
stablediffusion/assets/stable-samples/upscaling/sampled-bear-x4.png DELETED

Git LFS Details

  • SHA256: d4f2aaa8eb3054cda0a6e8577170d09c1494809cceca21973497602e17a22f1e
  • Pointer size: 132 Bytes
  • Size of remote file: 3.16 MB
stablediffusion/assets/stable-samples/upscaling/snow-leopard-x4.png DELETED

Git LFS Details

  • SHA256: fe8231dddcf77ada4b46f6949b4ea7757ff2d006253e1807ba6e1168077aad19
  • Pointer size: 132 Bytes
  • Size of remote file: 3.89 MB
stablediffusion/configs/stable-diffusion/v2-inference-v.yaml DELETED
@@ -1,68 +0,0 @@
1
- model:
2
- base_learning_rate: 1.0e-4
3
- target: ldm.models.diffusion.ddpm.LatentDiffusion
4
- params:
5
- parameterization: "v"
6
- linear_start: 0.00085
7
- linear_end: 0.0120
8
- num_timesteps_cond: 1
9
- log_every_t: 200
10
- timesteps: 1000
11
- first_stage_key: "jpg"
12
- cond_stage_key: "txt"
13
- image_size: 64
14
- channels: 4
15
- cond_stage_trainable: false
16
- conditioning_key: crossattn
17
- monitor: val/loss_simple_ema
18
- scale_factor: 0.18215
19
- use_ema: False # we set this to false because this is an inference only config
20
-
21
- unet_config:
22
- target: ldm.modules.diffusionmodules.openaimodel.UNetModel
23
- params:
24
- use_checkpoint: True
25
- use_fp16: True
26
- image_size: 32 # unused
27
- in_channels: 4
28
- out_channels: 4
29
- model_channels: 320
30
- attention_resolutions: [ 4, 2, 1 ]
31
- num_res_blocks: 2
32
- channel_mult: [ 1, 2, 4, 4 ]
33
- num_head_channels: 64 # need to fix for flash-attn
34
- use_spatial_transformer: True
35
- use_linear_in_transformer: True
36
- transformer_depth: 1
37
- context_dim: 1024
38
- legacy: False
39
-
40
- first_stage_config:
41
- target: ldm.models.autoencoder.AutoencoderKL
42
- params:
43
- embed_dim: 4
44
- monitor: val/rec_loss
45
- ddconfig:
46
- #attn_type: "vanilla-xformers"
47
- double_z: true
48
- z_channels: 4
49
- resolution: 256
50
- in_channels: 3
51
- out_ch: 3
52
- ch: 128
53
- ch_mult:
54
- - 1
55
- - 2
56
- - 4
57
- - 4
58
- num_res_blocks: 2
59
- attn_resolutions: []
60
- dropout: 0.0
61
- lossconfig:
62
- target: torch.nn.Identity
63
-
64
- cond_stage_config:
65
- target: ldm.modules.encoders.modules.FrozenOpenCLIPEmbedder
66
- params:
67
- freeze: True
68
- layer: "penultimate"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
stablediffusion/configs/stable-diffusion/v2-inference.yaml DELETED
@@ -1,67 +0,0 @@
1
- model:
2
- base_learning_rate: 1.0e-4
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
15
- conditioning_key: crossattn
16
- monitor: val/loss_simple_ema
17
- scale_factor: 0.18215
18
- use_ema: False # we set this to false because this is an inference only config
19
-
20
- unet_config:
21
- target: ldm.modules.diffusionmodules.openaimodel.UNetModel
22
- params:
23
- use_checkpoint: True
24
- use_fp16: True
25
- image_size: 32 # unused
26
- in_channels: 4
27
- out_channels: 4
28
- model_channels: 320
29
- attention_resolutions: [ 4, 2, 1 ]
30
- num_res_blocks: 2
31
- channel_mult: [ 1, 2, 4, 4 ]
32
- num_head_channels: 64 # need to fix for flash-attn
33
- use_spatial_transformer: True
34
- use_linear_in_transformer: True
35
- transformer_depth: 1
36
- context_dim: 1024
37
- legacy: False
38
-
39
- first_stage_config:
40
- target: ldm.models.autoencoder.AutoencoderKL
41
- params:
42
- embed_dim: 4
43
- monitor: val/rec_loss
44
- ddconfig:
45
- #attn_type: "vanilla-xformers"
46
- double_z: true
47
- z_channels: 4
48
- resolution: 256
49
- in_channels: 3
50
- out_ch: 3
51
- ch: 128
52
- ch_mult:
53
- - 1
54
- - 2
55
- - 4
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.FrozenOpenCLIPEmbedder
65
- params:
66
- freeze: True
67
- layer: "penultimate"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
stablediffusion/configs/stable-diffusion/v2-inpainting-inference.yaml DELETED
@@ -1,158 +0,0 @@
1
- model:
2
- base_learning_rate: 5.0e-05
3
- target: ldm.models.diffusion.ddpm.LatentInpaintDiffusion
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
15
- conditioning_key: hybrid
16
- scale_factor: 0.18215
17
- monitor: val/loss_simple_ema
18
- finetune_keys: null
19
- use_ema: False
20
-
21
- unet_config:
22
- target: ldm.modules.diffusionmodules.openaimodel.UNetModel
23
- params:
24
- use_checkpoint: True
25
- image_size: 32 # unused
26
- in_channels: 9
27
- out_channels: 4
28
- model_channels: 320
29
- attention_resolutions: [ 4, 2, 1 ]
30
- num_res_blocks: 2
31
- channel_mult: [ 1, 2, 4, 4 ]
32
- num_head_channels: 64 # need to fix for flash-attn
33
- use_spatial_transformer: True
34
- use_linear_in_transformer: True
35
- transformer_depth: 1
36
- context_dim: 1024
37
- legacy: False
38
-
39
- first_stage_config:
40
- target: ldm.models.autoencoder.AutoencoderKL
41
- params:
42
- embed_dim: 4
43
- monitor: val/rec_loss
44
- ddconfig:
45
- #attn_type: "vanilla-xformers"
46
- double_z: true
47
- z_channels: 4
48
- resolution: 256
49
- in_channels: 3
50
- out_ch: 3
51
- ch: 128
52
- ch_mult:
53
- - 1
54
- - 2
55
- - 4
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.FrozenOpenCLIPEmbedder
65
- params:
66
- freeze: True
67
- layer: "penultimate"
68
-
69
-
70
- data:
71
- target: ldm.data.laion.WebDataModuleFromConfig
72
- params:
73
- tar_base: null # for concat as in LAION-A
74
- p_unsafe_threshold: 0.1
75
- filter_word_list: "data/filters.yaml"
76
- max_pwatermark: 0.45
77
- batch_size: 8
78
- num_workers: 6
79
- multinode: True
80
- min_size: 512
81
- train:
82
- shards:
83
- - "pipe:aws s3 cp s3://stability-aws/laion-a-native/part-0/{00000..18699}.tar -"
84
- - "pipe:aws s3 cp s3://stability-aws/laion-a-native/part-1/{00000..18699}.tar -"
85
- - "pipe:aws s3 cp s3://stability-aws/laion-a-native/part-2/{00000..18699}.tar -"
86
- - "pipe:aws s3 cp s3://stability-aws/laion-a-native/part-3/{00000..18699}.tar -"
87
- - "pipe:aws s3 cp s3://stability-aws/laion-a-native/part-4/{00000..18699}.tar -" #{00000-94333}.tar"
88
- shuffle: 10000
89
- image_key: jpg
90
- image_transforms:
91
- - target: torchvision.transforms.Resize
92
- params:
93
- size: 512
94
- interpolation: 3
95
- - target: torchvision.transforms.RandomCrop
96
- params:
97
- size: 512
98
- postprocess:
99
- target: ldm.data.laion.AddMask
100
- params:
101
- mode: "512train-large"
102
- p_drop: 0.25
103
- # NOTE use enough shards to avoid empty validation loops in workers
104
- validation:
105
- shards:
106
- - "pipe:aws s3 cp s3://deep-floyd-s3/datasets/laion_cleaned-part5/{93001..94333}.tar - "
107
- shuffle: 0
108
- image_key: jpg
109
- image_transforms:
110
- - target: torchvision.transforms.Resize
111
- params:
112
- size: 512
113
- interpolation: 3
114
- - target: torchvision.transforms.CenterCrop
115
- params:
116
- size: 512
117
- postprocess:
118
- target: ldm.data.laion.AddMask
119
- params:
120
- mode: "512train-large"
121
- p_drop: 0.25
122
-
123
- lightning:
124
- find_unused_parameters: True
125
- modelcheckpoint:
126
- params:
127
- every_n_train_steps: 5000
128
-
129
- callbacks:
130
- metrics_over_trainsteps_checkpoint:
131
- params:
132
- every_n_train_steps: 10000
133
-
134
- image_logger:
135
- target: main.ImageLogger
136
- params:
137
- enable_autocast: False
138
- disabled: False
139
- batch_frequency: 1000
140
- max_images: 4
141
- increase_log_steps: False
142
- log_first_step: False
143
- log_images_kwargs:
144
- use_ema_scope: False
145
- inpaint: False
146
- plot_progressive_rows: False
147
- plot_diffusion_rows: False
148
- N: 4
149
- unconditional_guidance_scale: 5.0
150
- unconditional_guidance_label: [""]
151
- ddim_steps: 50 # todo check these out for depth2img,
152
- ddim_eta: 0.0 # todo check these out for depth2img,
153
-
154
- trainer:
155
- benchmark: True
156
- val_check_interval: 5000000
157
- num_sanity_val_steps: 0
158
- accumulate_grad_batches: 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
stablediffusion/configs/stable-diffusion/v2-midas-inference.yaml DELETED
@@ -1,74 +0,0 @@
1
- model:
2
- base_learning_rate: 5.0e-07
3
- target: ldm.models.diffusion.ddpm.LatentDepth2ImageDiffusion
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
15
- conditioning_key: hybrid
16
- scale_factor: 0.18215
17
- monitor: val/loss_simple_ema
18
- finetune_keys: null
19
- use_ema: False
20
-
21
- depth_stage_config:
22
- target: ldm.modules.midas.api.MiDaSInference
23
- params:
24
- model_type: "dpt_hybrid"
25
-
26
- unet_config:
27
- target: ldm.modules.diffusionmodules.openaimodel.UNetModel
28
- params:
29
- use_checkpoint: True
30
- image_size: 32 # unused
31
- in_channels: 5
32
- out_channels: 4
33
- model_channels: 320
34
- attention_resolutions: [ 4, 2, 1 ]
35
- num_res_blocks: 2
36
- channel_mult: [ 1, 2, 4, 4 ]
37
- num_head_channels: 64 # need to fix for flash-attn
38
- use_spatial_transformer: True
39
- use_linear_in_transformer: True
40
- transformer_depth: 1
41
- context_dim: 1024
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
- #attn_type: "vanilla-xformers"
51
- double_z: true
52
- z_channels: 4
53
- resolution: 256
54
- in_channels: 3
55
- out_ch: 3
56
- ch: 128
57
- ch_mult:
58
- - 1
59
- - 2
60
- - 4
61
- - 4
62
- num_res_blocks: 2
63
- attn_resolutions: [ ]
64
- dropout: 0.0
65
- lossconfig:
66
- target: torch.nn.Identity
67
-
68
- cond_stage_config:
69
- target: ldm.modules.encoders.modules.FrozenOpenCLIPEmbedder
70
- params:
71
- freeze: True
72
- layer: "penultimate"
73
-
74
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
stablediffusion/configs/stable-diffusion/x4-upscaling.yaml DELETED
@@ -1,76 +0,0 @@
1
- model:
2
- base_learning_rate: 1.0e-04
3
- target: ldm.models.diffusion.ddpm.LatentUpscaleDiffusion
4
- params:
5
- parameterization: "v"
6
- low_scale_key: "lr"
7
- linear_start: 0.0001
8
- linear_end: 0.02
9
- num_timesteps_cond: 1
10
- log_every_t: 200
11
- timesteps: 1000
12
- first_stage_key: "jpg"
13
- cond_stage_key: "txt"
14
- image_size: 128
15
- channels: 4
16
- cond_stage_trainable: false
17
- conditioning_key: "hybrid-adm"
18
- monitor: val/loss_simple_ema
19
- scale_factor: 0.08333
20
- use_ema: False
21
-
22
- low_scale_config:
23
- target: ldm.modules.diffusionmodules.upscaling.ImageConcatWithNoiseAugmentation
24
- params:
25
- noise_schedule_config: # image space
26
- linear_start: 0.0001
27
- linear_end: 0.02
28
- max_noise_level: 350
29
-
30
- unet_config:
31
- target: ldm.modules.diffusionmodules.openaimodel.UNetModel
32
- params:
33
- use_checkpoint: True
34
- num_classes: 1000 # timesteps for noise conditioning (here constant, just need one)
35
- image_size: 128
36
- in_channels: 7
37
- out_channels: 4
38
- model_channels: 256
39
- attention_resolutions: [ 2,4,8]
40
- num_res_blocks: 2
41
- channel_mult: [ 1, 2, 2, 4]
42
- disable_self_attentions: [True, True, True, False]
43
- disable_middle_self_attn: False
44
- num_heads: 8
45
- use_spatial_transformer: True
46
- transformer_depth: 1
47
- context_dim: 1024
48
- legacy: False
49
- use_linear_in_transformer: True
50
-
51
- first_stage_config:
52
- target: ldm.models.autoencoder.AutoencoderKL
53
- params:
54
- embed_dim: 4
55
- ddconfig:
56
- # attn_type: "vanilla-xformers" this model needs efficient attention to be feasible on HR data, also the decoder seems to break in half precision (UNet is fine though)
57
- double_z: True
58
- z_channels: 4
59
- resolution: 256
60
- in_channels: 3
61
- out_ch: 3
62
- ch: 128
63
- ch_mult: [ 1,2,4 ] # num_down = len(ch_mult)-1
64
- num_res_blocks: 2
65
- attn_resolutions: [ ]
66
- dropout: 0.0
67
-
68
- lossconfig:
69
- target: torch.nn.Identity
70
-
71
- cond_stage_config:
72
- target: ldm.modules.encoders.modules.FrozenOpenCLIPEmbedder
73
- params:
74
- freeze: True
75
- layer: "penultimate"
76
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
stablediffusion/environment.yaml DELETED
@@ -1,29 +0,0 @@
1
- name: ldm
2
- channels:
3
- - pytorch
4
- - defaults
5
- dependencies:
6
- - python=3.8.5
7
- - pip=20.3
8
- - cudatoolkit=11.3
9
- - pytorch=1.12.1
10
- - torchvision=0.13.1
11
- - numpy=1.23.1
12
- - pip:
13
- - albumentations==1.3.0
14
- - opencv-python==4.6.0.66
15
- - imageio==2.9.0
16
- - imageio-ffmpeg==0.4.2
17
- - pytorch-lightning==1.4.2
18
- - omegaconf==2.1.1
19
- - test-tube>=0.7.5
20
- - streamlit==1.12.1
21
- - einops==0.3.0
22
- - transformers==4.19.2
23
- - webdataset==0.2.5
24
- - kornia==0.6
25
- - open_clip_torch==2.0.2
26
- - invisible-watermark>=0.1.5
27
- - streamlit-drawable-canvas==0.8.0
28
- - torchmetrics==0.6.0
29
- - -e .