Skip to content

models runwayml stable diffusion inpainting

github-actions[bot] edited this page Oct 8, 2024 · 19 revisions

runwayml-stable-diffusion-inpainting

Overview

Stable Diffusion Inpainting is a latent text-to-image diffusion model capable of generating photo-realistic images given any text input, with the extra capability of inpainting the pictures by using a mask.

The Stable-Diffusion-Inpainting was initialized with the weights of the Stable-Diffusion-v-1-2. First 595k steps regular training, then 440k steps of inpainting training at resolution 512x512 on “laion-aesthetics v2 5+” and 10% dropping of the text-conditioning to improve classifier-free classifier-free guidance sampling. 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. During training, we generate synthetic masks and in 25% mask everything.

The model is intended for research purposes only. Possible research areas and tasks include

  • Safe deployment of models which have 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.

Training Details

Training Data

The model developers used the following dataset for training the model:

  • LAION-2B (en) and subsets thereof (see next section)

Training Procedure

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,

  • 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
  • Text prompts are encoded through 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 noise that was added to the latent and the prediction made by the UNet.

We currently provide following checkpoint, which was trained as follows,

  • sd-v1-5-inpaint.ckpt: Resumed from sd-v1-2.ckpt. 595k steps at resolution 512x512 on "laion-aesthetics v2 5+" and 10% dropping of the text-conditioning to improve classifier-free guidance sampling. Then 440k steps of inpainting training at resolution 512x512 on “laion-aesthetics v2 5+” and 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. During training, we generate synthetic masks and in 25% mask everything.

  • Hardware: 32 x 8 x A100 GPUs

  • Optimizer: AdamW

  • Gradient Accumulations: 2

  • Batch: 32 x 8 x 2 x 4 = 2048

  • Learning rate: warmup to 0.0001 for 10,000 steps and then kept constant

Evaluation Results

Evaluations with different classifier-free guidance scales (1.5, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0) and 50 PLMS sampling steps show the relative improvements of the checkpoints:

pareto

Evaluated using 50 PLMS steps and 10000 random prompts from the COCO2017 validation set, evaluated at 512x512 resolution. Not optimized for FID scores.

Limitations and Biases

Limitations

  • The model does not achieve perfect photorealism
  • The model cannot render legible text
  • 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”
  • Faces and people in general may not be generated properly.
  • The model was trained mainly with English captions and will not work as well in other languages.
  • The autoencoding part of the model is lossy
  • The model was trained on a large-scale dataset LAION-5B which contains adult material and is not fit for product use without additional safety mechanisms and considerations.
  • 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. The training data can be searched at https://rom1504.github.io/clip-retrieval/ to possibly assist in the detection of memorized images.

Bias

While the capabilities of image generation models are impressive, they can also reinforce or exacerbate social biases. Stable Diffusion v1 was trained on subsets of LAION-2B(en), which consists of images that are primarily limited to English descriptions. Texts and images from communities and cultures that use other languages are likely to be insufficiently accounted for. This affects the overall output of the model, as white and western cultures are often set as the default.Further, the ability of the model to generate content with non-English prompts is significantly worse than with English-language prompts.

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.

Out-of-Scope Use

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.

Misuse and Malicious Use

Using the model to generate content that is cruel to individuals is a misuse of this model. This includes, but is not limited to:

  • Generating demeaning, dehumanizing, or otherwise harmful representations of people or their environments, cultures, religions, etc.
  • Intentionally promoting or propagating discriminatory content or harmful stereotypes.
  • Impersonating individuals without their consent.
  • Sexual content without consent of the people who might see it.
  • Mis- and disinformation
  • Representations of egregious violence and gore
  • Sharing of copyrighted or licensed material in violation of its terms of use.
  • Sharing content that is an alteration of copyrighted or licensed material in violation of its terms of use.

License

The CreativeML OpenRAIL M license is an Open RAIL M license, adapted from the work that BigScience and the RAIL Initiative are jointly carrying in the area of responsible AI licensing. See also the article about the BLOOM Open RAIL license on which our license is based.

Inference Samples

Inference type Python sample (Notebook) CLI with YAML
Real time text-to-image-inpainting-online-endpoint.ipynb text-to-image-inpainting-online-endpoint.sh
Batch text-to-image-inpainting-batch-endpoint.ipynb text-to-image-inpainting-batch-endpoint.sh

Inference with Azure AI Content Safety (AACS) samples

Inference type Python sample (Notebook)
Real time safe-text-to-image-inpainting-online-deployment.ipynb
Batch safe-text-to-image-inpainting-batch-endpoint.ipynb

Sample input and output

Sample input

{
   "input_data": {
        "columns": ["prompt", "image", "mask"],
        "data": [
            {
                "prompt": "Face of a yellow cat, high resolution, sitting on a park bench",
                "image": "image1",
                "mask_image": "mask1"
            },
            {
                "prompt": "Face of a green cat, high resolution, sitting on a park bench",
                "image": "image2",
                "mask_image": "mask2"
            }
        ],
        "index": [0, 1]
    }
}

Note:

  • "image1" and "image2" strings are base64 format.
  • "mask1" and "mask2" strings are base64 format.

Sample output

[
    {
        "prompt": "Face of a yellow cat, high resolution, sitting on a park bench",
        "generated_image": "inpainted_image1",
        "nsfw_content_detected": false
    },
    {
        "prompt": "Face of a green cat, high resolution, sitting on a park bench",
        "generated_image": "inpainted_image2",
        "nsfw_content_detected": false
    }
]

Note:

  • "inpainted_image1" and "inpainted_image2" strings are base64 format.
  • If "nsfw_content_detected" is True then generated image will be totally black.

Visualization for the prompt - "a small flower vase featuring a blend of yellow and orange"

runwayml_stable_diffusion_inpainting input image mask image and output visualization

Version: 10

Tags

SharedComputeCapacityEnabled license : creativeml-openrail-m task : text-to-image hiddenlayerscanned training_dataset : LAION aesthetics v2.5+ author : Runway huggingface_model_id : runwayml/stable-diffusion-inpainting inference_compute_allow_list : ['Standard_NC6s_v3', 'Standard_NC12s_v3', 'Standard_NC24s_v3', 'Standard_ND40rs_v2', 'Standard_ND96amsr_A100_v4', 'Standard_ND96asr_v4']

View in Studio: https://ml.azure.com/registries/azureml/models/runwayml-stable-diffusion-inpainting/version/10

License: creativeml-openrail-m

Properties

SharedComputeCapacityEnabled: True

SHA: 51388a731f57604945fddd703ecb5c50e8e7b49d

inference-min-sku-spec: 6|1|112|736

inference-recommended-sku: Standard_NC6s_v3, Standard_NC12s_v3, Standard_NC24s_v3, Standard_ND40rs_v2, Standard_ND96amsr_A100_v4, Standard_ND96asr_v4

Clone this wiki locally