readme: ---
  license: creativeml-openrail-m
  tags:
  - stable-diffusion
  - stable-diffusion-diffusers
  - text-to-image
  inference: false
  extra_gated_prompt: |-
    One more step before getting this model.
    This model is open access and available to all, with a CreativeML OpenRAIL-M license further specifying rights and usage.
    The CreativeML OpenRAIL License specifies: 
    1. You can't use the model to deliberately produce nor share illegal or harmful outputs or content 
    2. CompVis claims no rights on the outputs you generate, you are free to use them and are accountable for their use which must not go against the provisions set in the license
    3. You may re-distribute the weights and use the model commercially and/or as a service. If you do, please be aware you have to include the same use restrictions as the ones in the license and share a copy of the CreativeML OpenRAIL-M to all your users (please read the license entirely and carefully)
    Please read the full license here: https://huggingface.co/spaces/CompVis/stable-diffusion-license
    
    By clicking on "Access repository" below, you accept that your *contact information* (email address and username) can be shared with the model authors as well:
      
  extra_gated_fields:
   I have read the License and agree with its terms: checkbox
  ---
  
  # Stable Diffusion v1-1 Model Card
  
  Stable Diffusion is a latent text-to-image diffusion model capable of generating photo-realistic images given any text input.
  For more information about how Stable Diffusion functions, please have a look at [🤗's Stable Diffusion with D🧨iffusers blog](https://huggingface.co/blog/stable_diffusion).
  
  The **Stable-Diffusion-v1-1** was trained on 237,000 steps at resolution `256x256` on [laion2B-en](https://huggingface.co/datasets/laion/laion2B-en), followed by
  194,000 steps at resolution `512x512` on [laion-high-resolution](https://huggingface.co/datasets/laion/laion-high-resolution) (170M examples from LAION-5B with resolution `>= 1024x1024`). For more information, please refer to [Training](#training).
  
  This weights here are intended to be used with the D🧨iffusers library. If you are looking for the weights to be loaded into the CompVis Stable Diffusion codebase, [come here](https://huggingface.co/CompVis/stable-diffusion-v-1-1-original)
  
  ## Model 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](https://huggingface.co/spaces/CompVis/stable-diffusion-license) is an [Open RAIL M license](https://www.licenses.ai/blog/2022/8/18/naming-convention-of-responsible-ai-licenses), adapted from the work that [BigScience](https://bigscience.huggingface.co/) and [the RAIL Initiative](https://www.licenses.ai/) are jointly carrying in the area of responsible AI licensing. See also [the article about the BLOOM Open RAIL license](https://bigscience.huggingface.co/blog/the-bigscience-rail-license) on which our license is based.
  - **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).
  - **Resources for more information:** [GitHub Repository](https://github.com/CompVis/stable-diffusion), [Paper](https://arxiv.org/abs/2112.10752).
  - **Cite as:**
  
        @InProceedings{Rombach_2022_CVPR,
            author    = {Rombach, Robin and Blattmann, Andreas and Lorenz, Dominik and Esser, Patrick and Ommer, Bj\"orn},
            title     = {High-Resolution Image Synthesis With Latent Diffusion Models},
            booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
            month     = {June},
            year      = {2022},
            pages     = {10684-10695}
        }
  
  ## Examples
  
  We recommend using [🤗's Diffusers library](https://github.com/huggingface/diffusers) to run Stable Diffusion.
  
  ```bash
  pip install --upgrade diffusers transformers scipy
  ```
  
  Run this command to log in with your HF Hub token if you haven't before:
  
  ```bash
  huggingface-cli login
  ```
  
  Running the pipeline with the default PNDM scheduler:
  
  ```python
  import torch
  from torch import autocast
  from diffusers import StableDiffusionPipeline
  
  model_id = "CompVis/stable-diffusion-v1-1"
  device = "cuda"
  
  
  pipe = StableDiffusionPipeline.from_pretrained(model_id, use_auth_token=True)
  pipe = pipe.to(device)
  
  prompt = "a photo of an astronaut riding a horse on mars"
  with autocast("cuda"):
      image = pipe(prompt, guidance_scale=7.5)["sample"][0]  
      
  image.save("astronaut_rides_horse.png")
  ```
  
  **Note**:
  If you are limited by GPU memory and have less than 10GB of GPU RAM available, please make sure to load the StableDiffusionPipeline in float16 precision instead of the default float32 precision as d