Model Overview
Model Features
Model Capabilities
Use Cases
🚀 Stable Diffusion v1-5
Stable Diffusion is a latent text-to-image diffusion model. It can generate photo-realistic images based on any text input, offering a powerful tool for various image generation tasks.
🚀 Quick Start
This repository is being re-uploaded to HuggingFace under The CreativeML OpenRAIL-M License, specifically Section II which grants:
...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.
Note that these files originated from modelscope, not HuggingFace. Some files in the original repository might be missing. File integrity has been verified via checksum.
✨ Features
- Text-to-Image Generation: Capable of generating photo-realistic images given any text input.
- License Compliance: Re-uploaded in accordance with the CreativeML OpenRAIL-M License.
📦 Installation
You can use this model with the 🧨Diffusers library.
💻 Usage Examples
Basic Usage
from diffusers import StableDiffusionPipeline
import torch
pipe = StableDiffusionPipeline.from_pretrained(
"benjamin-paine/stable-diffusion-v1-5",
torch_dtype=torch.float16
)
pipe = pipe.to("cuda")
prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt).images[0]
image.save("astronaut_rides_horse.png")
For more detailed instructions, use-cases and examples in JAX, follow the instructions here.
📚 Documentation
Model Details
Property | Details |
---|---|
Developed by | Robin Rombach, Patrick Esser |
Model Type | Diffusion-based text-to-image generation model |
Language(s) | English |
License | The CreativeML OpenRAIL M license, an Open RAIL M license, adapted from the work of BigScience and the RAIL Initiative. See also the article about the BLOOM Open RAIL license. |
Model Description | A model for generating and modifying images based on text prompts. It's a Latent Diffusion Model using a fixed, pretrained text encoder (CLIP ViT-L/14) as suggested in the Imagen paper. |
Resources for more information | GitHub Repository, Paper |
Cite as | @InProceedings{Rombach_2022_CVPR, |
Uses
Direct Use
The model is for research purposes only. Possible research areas and tasks include:
- Safe deployment of models with the potential to generate harmful content.
- Probing and understanding the limitations and biases of generative models.
- Generation of artworks and use in design and other artistic processes.
- Applications in educational or creative tools.
- Research on generative models.
Excluded uses are described below.
Misuse, Malicious Use, and Out-of-Scope Use
⚠️ Important Note
This section is taken from the DALLE-MINI model card, but applies in the same way to Stable Diffusion v1.
The model should not be used to intentionally create or disseminate images that create hostile or alienating environments for people. This includes generating disturbing, distressing, or offensive images, or content that propagates historical or current stereotypes.
Out-of-Scope Use
The model was not trained to provide factual or true representations of people or events. Using it to generate such content is beyond its capabilities.
Misuse and Malicious Use
Using the model to generate cruel content towards individuals is a misuse. This includes, but is not limited to:
- Generating demeaning, dehumanizing, or harmful representations of people, their environments, cultures, religions, etc.
- Intentionally promoting or propagating discriminatory content or harmful stereotypes.
- Impersonating individuals without consent.
- Generating sexual content without the consent of those who might see it.
- Spreading mis- and disinformation.
- Representing egregious violence and gore.
- Sharing copyrighted or licensed material in violation of its terms of use.
- Sharing altered copyrighted or licensed material in violation of its terms of use.
Limitations and Bias
Limitations
- The model does not achieve perfect photorealism.
- It cannot render legible text.
- It performs poorly on more complex tasks involving compositionality, such as rendering an image of “A red cube on top of a blue sphere”.
- Faces and people may not be generated properly.
- Trained mainly with English captions, it works less well in other languages.
- The autoencoding part of the model is lossy.
- Trained on the LAION-5B dataset which contains adult material, it's not suitable for product use without additional safety mechanisms.
- No additional deduplication measures were used on the dataset, resulting in some memorization of duplicated images. The training data can be searched at https://rom1504.github.io/clip-retrieval/ to detect memorized images.
Bias
Image generation models can reinforce or exacerbate social biases. Stable Diffusion v1 was trained on subsets of LAION-2B(en), mainly with English descriptions. Texts and images from non-English communities and cultures are underrepresented, affecting the model's output. The model performs significantly worse with non-English prompts.
Safety Module
The model is intended to be used with the Safety Checker in Diffusers. This checker compares model outputs against known hard-coded NSFW concepts in the embedding space of the CLIPTextModel
after image generation. The concepts are hidden to prevent reverse-engineering.
Training
Training Data
The model was trained on the following dataset:
- LAION-2B (en) and subsets thereof.
Training Procedure
Stable Diffusion v1-5 is a latent diffusion model that combines an autoencoder with a diffusion model trained in the autoencoder's latent space. During training:
- Images are encoded by an encoder into latent representations. The autoencoder uses a relative downsampling factor of 8, mapping images of shape H x W x 3 to latents of shape H/f x W/f x 4.
- Text prompts are encoded by a ViT-L/14 text-encoder.
- The non-pooled output of the text encoder is fed into the UNet backbone of the latent diffusion model via cross-attention.
- The loss is a reconstruction objective between the added noise in the latent and the UNet's prediction.
Currently, six Stable Diffusion checkpoints are available, trained as follows:
stable-diffusion-v1-1
: 237,000 steps at resolution256x256
on laion2B-en, then 194,000 steps at resolution512x512
on laion-high-resolution (170M examples from LAION-5B with resolution>= 1024x1024
).stable-diffusion-v1-2
: Resumed fromstable-diffusion-v1-1
, 515,000 steps at resolution512x512
on "laion-improved-aesthetics" (a subset of laion2B-en, filtered to images with an original size>= 512x512
, estimated aesthetics score> 5.0
, and an estimated watermark probability< 0.5
).stable-diffusion-v1-3
: Resumed fromstable-diffusion-v1-2
, 195,000 steps at resolution512x512
on "laion-improved-aesthetics" with 10% dropping of the text-conditioning to improve classifier-free guidance sampling.stable-diffusion-v1-4
: Resumed fromstable-diffusion-v1-2
, 225,000 steps at resolution512x512
on "laion-aesthetics v2 5+" with 10% dropping of the text-conditioning to improve classifier-free guidance sampling.stable-diffusion-v1-5
: Resumed fromstable-diffusion-v1-2
, 595,000 steps at resolution512x512
on "laion-aesthetics v2 5+" with 10% dropping of the text-conditioning to improve classifier-free guidance sampling.stable-diffusion-v1-5-inpainting
: Resumed fromstable-diffusion-v1-5
, then 440,000 steps of inpainting training at resolution 512x512 on “laion-aesthetics v2 5+” with 10% dropping of the text-conditioning. For inpainting, the UNet has 5 additional input channels (4 for the encoded masked-image and 1 for the mask itself) whose weights were zero-initialized after restoring the non-inpainting checkpoint.
📄 License
This repository is re-uploaded under The CreativeML OpenRAIL-M License.