justinpinkney
commited on
Commit
•
8fa04f7
1
Parent(s):
273115e
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
thumbnail: "https://repository-images.githubusercontent.com/523487884/fdb03a69-8353-4387-b5fc-0d85f888a63f"
|
3 |
+
datasets:
|
4 |
+
- ChristophSchuhmann/improved_aesthetics_6plus
|
5 |
+
license: other
|
6 |
+
tags:
|
7 |
+
- stable-diffusion
|
8 |
+
- stable-diffusion-diffusers
|
9 |
+
- image-to-image
|
10 |
+
---
|
11 |
+
|
12 |
+
# Stable Diffusion Image Variations Model Card
|
13 |
+
|
14 |
+
This version of Stable Diffusion has been fine tuned from [CompVis/stable-diffusion-v1-3-original](https://huggingface.co/CompVis/stable-diffusion-v-1-3-original) to accept CLIP image embedding rather than text embeddings. This allows the creation of "image variations" similar to DALLE-2 using Stable Diffusion. This version of the weights has been ported to huggingface Diffusers, to use this with the Diffusers library requires the [Lambda Diffusers repo](https://github.com/LambdaLabsML/lambda-diffusers).
|
15 |
+
|
16 |
+
## Example
|
17 |
+
|
18 |
+
First clone [Lambda Diffusers](https://github.com/LambdaLabsML/lambda-diffusers) and install any requirements (in a virtual environment in the example below):
|
19 |
+
|
20 |
+
```bash
|
21 |
+
git clone https://github.com/LambdaLabsML/lambda-diffusers.git
|
22 |
+
cd lambda-diffusers
|
23 |
+
python -m venv .venv
|
24 |
+
source .venv/bin/activate
|
25 |
+
pip install -r requirements.txt
|
26 |
+
```
|
27 |
+
|
28 |
+
Then run the following python code:
|
29 |
+
|
30 |
+
```python
|
31 |
+
from pathlib import Path
|
32 |
+
from lambda_diffusers import StableDiffusionImageEmbedPipeline
|
33 |
+
from PIL import Image
|
34 |
+
import torch
|
35 |
+
|
36 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
37 |
+
pipe = StableDiffusionImageEmbedPipeline.from_pretrained("lambdalabs/sd-image-variations-diffusers")
|
38 |
+
pipe = pipe.to(device)
|
39 |
+
|
40 |
+
im = Image.open("your/input/image/here.jpg")
|
41 |
+
num_samples = 4
|
42 |
+
image = pipe(num_samples*[im], guidance_scale=3.0)
|
43 |
+
image = image["sample"]
|
44 |
+
|
45 |
+
base_path = Path("outputs/im2im")
|
46 |
+
base_path.mkdir(exist_ok=True, parents=True)
|
47 |
+
for idx, im in enumerate(image):
|
48 |
+
im.save(base_path/f"{idx:06}.jpg")
|
49 |
+
```
|
50 |
+
|
51 |
+
|
52 |
+
# Training
|
53 |
+
|
54 |
+
**Training Data**
|
55 |
+
The model developers used the following dataset for training the model:
|
56 |
+
|
57 |
+
- LAION-2B (en) and subsets thereof (see next section)
|
58 |
+
|
59 |
+
**Training Procedure**
|
60 |
+
This model is fine tuned from Stable Diffusion v1-3 where the text encoder has been replaced with an image encoder. The training procedure is the same as for Stable Diffusion except for the fact that images are encoded through a ViT-L/14 image-encoder including the final projection layer to the CLIP shared embedding space.
|
61 |
+
|
62 |
+
- **Hardware:** 4 x A6000 GPUs (provided by [Lambda GPU Cloud](https://lambdalabs.com/service/gpu-cloud))
|
63 |
+
- **Optimizer:** AdamW
|
64 |
+
- **Gradient Accumulations**: 1
|
65 |
+
- **Steps**: 87,000
|
66 |
+
- **Batch:** 6 x 4 = 24
|
67 |
+
- **Learning rate:** warmup to 0.0001 for 1,000 steps and then kept constant
|
68 |
+
|
69 |
+
Training was done using a [modified version of the original Stable Diffusion training code]((https://github.com/justinpinkney/stable-diffusion)
|
70 |
+
|
71 |
+
|
72 |
+
# Uses
|
73 |
+
_The following section is adapted from the [Stable Diffusion model card](https://huggingface.co/CompVis/stable-diffusion-v1-4)_
|
74 |
+
|
75 |
+
## Direct Use
|
76 |
+
The model is intended for research purposes only. Possible research areas and
|
77 |
+
tasks include
|
78 |
+
|
79 |
+
- Safe deployment of models which have the potential to generate harmful content.
|
80 |
+
- Probing and understanding the limitations and biases of generative models.
|
81 |
+
- Generation of artworks and use in design and other artistic processes.
|
82 |
+
- Applications in educational or creative tools.
|
83 |
+
- Research on generative models.
|
84 |
+
|
85 |
+
Excluded uses are described below.
|
86 |
+
|
87 |
+
### Misuse, Malicious Use, and Out-of-Scope Use
|
88 |
+
|
89 |
+
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.
|
90 |
+
|
91 |
+
#### Out-of-Scope Use
|
92 |
+
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.
|
93 |
+
|
94 |
+
#### Misuse and Malicious Use
|
95 |
+
Using the model to generate content that is cruel to individuals is a misuse of this model. This includes, but is not limited to:
|
96 |
+
|
97 |
+
- Generating demeaning, dehumanizing, or otherwise harmful representations of people or their environments, cultures, religions, etc.
|
98 |
+
- Intentionally promoting or propagating discriminatory content or harmful stereotypes.
|
99 |
+
- Impersonating individuals without their consent.
|
100 |
+
- Sexual content without consent of the people who might see it.
|
101 |
+
- Mis- and disinformation
|
102 |
+
- Representations of egregious violence and gore
|
103 |
+
- Sharing of copyrighted or licensed material in violation of its terms of use.
|
104 |
+
- Sharing content that is an alteration of copyrighted or licensed material in violation of its terms of use.
|
105 |
+
|
106 |
+
## Limitations and Bias
|
107 |
+
|
108 |
+
### Limitations
|
109 |
+
|
110 |
+
- The model does not achieve perfect photorealism
|
111 |
+
- The model cannot render legible text
|
112 |
+
- 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”
|
113 |
+
- Faces and people in general may not be generated properly.
|
114 |
+
- The model was trained mainly with English captions and will not work as well in other languages.
|
115 |
+
- The autoencoding part of the model is lossy
|
116 |
+
- The model was trained on a large-scale dataset
|
117 |
+
[LAION-5B](https://laion.ai/blog/laion-5b/) which contains adult material
|
118 |
+
and is not fit for product use without additional safety mechanisms and
|
119 |
+
considerations.
|
120 |
+
- No additional measures were used to deduplicate the dataset. As a result, we observe some degree of memorization for images that are duplicated in the training data.
|
121 |
+
The training data can be searched at [https://rom1504.github.io/clip-retrieval/](https://rom1504.github.io/clip-retrieval/) to possibly assist in the detection of memorized images.
|
122 |
+
|
123 |
+
### Bias
|
124 |
+
|
125 |
+
While the capabilities of image generation models are impressive, they can also reinforce or exacerbate social biases.
|
126 |
+
Stable Diffusion v1 was trained on subsets of [LAION-2B(en)](https://laion.ai/blog/laion-5b/),
|
127 |
+
which consists of images that are primarily limited to English descriptions.
|
128 |
+
Texts and images from communities and cultures that use other languages are likely to be insufficiently accounted for.
|
129 |
+
This affects the overall output of the model, as white and western cultures are often set as the default. Further, the
|
130 |
+
ability of the model to generate content with non-English prompts is significantly worse than with English-language prompts.
|
131 |
+
|
132 |
+
### Safety Module
|
133 |
+
|
134 |
+
The intended use of this model is with the [Safety Checker](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/safety_checker.py) in Diffusers.
|
135 |
+
This checker works by checking model outputs against known hard-coded NSFW concepts.
|
136 |
+
The concepts are intentionally hidden to reduce the likelihood of reverse-engineering this filter.
|
137 |
+
Specifically, the checker compares the class probability of harmful concepts in the embedding space of the `CLIPModel` *after generation* of the images.
|
138 |
+
The concepts are passed into the model with the generated image and compared to a hand-engineered weight for each NSFW concept.
|
139 |
+
|
140 |
+
|
141 |
+
## Citation
|
142 |
+
|
143 |
+
```bibtex
|
144 |
+
@InProceedings{Rombach_2022_CVPR,
|
145 |
+
author = {Rombach, Robin and Blattmann, Andreas and Lorenz, Dominik and Esser, Patrick and Ommer, Bj\"orn},
|
146 |
+
title = {High-Resolution Image Synthesis With Latent Diffusion Models},
|
147 |
+
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
|
148 |
+
month = {June},
|
149 |
+
year = {2022},
|
150 |
+
pages = {10684-10695}
|
151 |
+
}
|
152 |
+
```
|
153 |
+
|
154 |
+
*This model card was written by: Justin Pinkney and is based on the [Stable Diffusion model card](https://huggingface.co/CompVis/stable-diffusion-v1-4).*
|