# Stable Diffusion Inpaint

## Try it in the Widget Center

Click this [url](https://app.myshell.ai/robot-workshop/widget/1782399147535691776) to try this widget and copy the Pro Config template.

## Usage

Utilize diffusion model to fill in the masked region of your image!

**Input Parameters**

<table><thead><tr><th>Name</th><th>Type</th><th>Description</th><th>Default</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>image</td><td><code>string</code></td><td>The input image, can be a url or base64 sting</td><td></td><td>true</td></tr><tr><td>mask</td><td><code>string</code></td><td>The correspond mask, can be a url or base64 sting. 1 for mask region</td><td></td><td>true</td></tr><tr><td>model</td><td><code>string</code></td><td>The model id from civitai (SD1.5, SDXL 1.0, PlaygroundV2). How to get it? Click on a model page on civitai, and copy the series number within the download link.</td><td>64094</td><td>true</td></tr><tr><td>prompt</td><td><code>string</code></td><td>The text prompt for image transformation. Add lora? add `` to your prompt. `$id` is the series number and `$weight` is the lora weight you want (always set to 1.0). You can use multiple loras.</td><td></td><td>true</td></tr><tr><td>negative_prompt</td><td><code>string</code></td><td>The negative prompt for image transformation.</td><td>(worst quality, low quality:1.4),(malformed hands:1.4),(poorly drawn hands:1.4),(mutated fingers:1.4),(extra limbs:1.35),(poorly drawn face:1.4),bad leg,strange leg, poor eyes, full screen of face</td><td>false</td></tr><tr><td>mask_blur</td><td><code>integer</code></td><td>Mask blur refers to the feathering of a mask (from edges to inside the mask), adjusted between 0-64. A smaller value results in sharper edges. Default to 4</td><td>4</td><td>false</td></tr><tr><td>inpainting_fill</td><td><code>integer</code></td><td>Choose the fill content in mask: 0 - fill, 1 - original, 2 - latent noise, 3 - latent nothing</td><td>1</td><td>false</td></tr><tr><td>inpainting_mask_invert</td><td><code>integer</code></td><td>0 - Inpaint masked region, 1 - Inpaint not masked region</td><td>0</td><td>false</td></tr><tr><td>sampler</td><td><code>string</code></td><td>Sampler for diffusion model inference</td><td>DPM++ 2M Karras</td><td>false</td></tr><tr><td>steps</td><td><code>integer</code></td><td>Steps for sampler to step whle sampling</td><td>25</td><td>false</td></tr><tr><td>cfg_scale</td><td><code>number</code></td><td>Classifier Free Guidance Scale - how strongly the image should conform to prompt - lower values produce more creative results. Default to 7.</td><td>7.0</td><td>false</td></tr><tr><td>seed</td><td><code>integer</code></td><td>Random seed for generation process. -1 means random seed</td><td>-1</td><td>false</td></tr><tr><td>clip_skip</td><td><code>integer</code></td><td>Early stopping parameter for CLIP model; 1 is stop at last layer as usual, 2 is stop at penultimate layer, etc.</td><td>1</td><td>false</td></tr><tr><td>denoising_strength</td><td><code>number</code></td><td>Strength of image transfomation during inpainting precess. High means more influence during transformation</td><td>0.7</td><td>false</td></tr></tbody></table>

**Output Parameters**

| Name | Type     | Description                                                                                                  | File Type |
| ---- | -------- | ------------------------------------------------------------------------------------------------------------ | --------- |
| url  | `string` | The url of generated image, stored in the cloud. Only temporarily effective, will be cleared in a few hours. | `image`   |

**Output Example**

{% tabs %}
{% tab title="success" %}
{% code fullWidth="false" %}

```json
{
  "url": "https://image.myshell.ai/image/chat/embed_obj/40295/20240423/2f1f812747e6468b959ea7dde217b78b.jpg"
}
```

{% endcode %}
{% endtab %}

{% tab title="fail" %}
{% code fullWidth="false" %}

```json
throw a Http error.
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Detailed Guidelines

* **inpaint**
  * Main parameter:
    * `image` : The input image, can be a url or base64 sting. Any size
    * `mask`: The correspond mask, can be a url or base64 sting. 1 means the masked region
    * `mask_blur` : Mask blur refers to the feathering of a mask (from edges to inside the mask), adjusted between 0-64. A smaller value results in sharper edges. Default to 4
    * `inpainting_fill` : Choose the fill content in mask: 0 - fill, 1 - original, 2 - latent noise, 3 - latent nothing. Default to 1
    * `inpainting_mask_invert`: 0 - Inpaint masked region, 1 - Inpaint not masked region
    * `denoising_strength`: Strength of image transfomation during inpainting precess. High means more influence during transformation


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://myshell-wiki.gitbook.io/proconfig-tutorial/api-reference/widgets/26-stable-diffusion-inpaint.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
