# ControlNet with Civitai

{% hint style="info" %}
This widget supports multiple actions. For a more comprehensive understanding of its functionality, we recommend reviewing the following documentation carefully.

You need to pass both the `action` and other input parameters of the chosen action to your `module_config`
{% endhint %}

## Try it in the Widget Center

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

## Usage

### Generate Picture with ControlNet

<mark style="color:green;">`action`</mark> `txt2img`

**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>action</td><td><code>string</code></td><td>The action of ControlNet, txt2img or img2img</td><td>txt2img</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>controlnet_model</td><td><code>string</code></td><td>The ControlNet model id from civitai. How to get it? Click on a model page on civitai, and copy the series number within the download link.</td><td>10971</td><td>true</td></tr><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>no_mask</td><td><code>boolean</code></td><td>Whether to use mask</td><td>False</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>false</td></tr><tr><td>prompt</td><td><code>string</code></td><td>The text prompt for ControlNet. 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 ControlNet.</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>true</td></tr><tr><td>controlnet_module</td><td><code>string</code></td><td>The ControNet module</td><td>none</td><td>true</td></tr><tr><td>guidance_start</td><td><code>number</code></td><td>ControlNet guidance start</td><td>0</td><td>true</td></tr><tr><td>guidance_end</td><td><code>number</code></td><td>ControlNet guidance end</td><td>1</td><td>true</td></tr><tr><td>control_mode</td><td><code>string</code></td><td>The improved guess mode</td><td>Balanced</td><td>true</td></tr><tr><td>weight</td><td><code>number</code></td><td>The weight of the controlnet model</td><td>1</td><td>true</td></tr><tr><td>resize_mode</td><td><code>string</code></td><td>Four modes for output shape calculation: (1) Keep: keep original shape, (2) Certain: based on input width/length (divisible by 32), (3,4) min/max ratio: keep aspect ratio, the resize factor is the min/max of (h/H, w/W).</td><td>certain</td><td>true</td></tr><tr><td>threshold_a</td><td><code>integer</code></td><td>The threshold A for controlnet model</td><td>64</td><td>true</td></tr><tr><td>threshold_b</td><td><code>integer</code></td><td>The threshold B for controlnet model</td><td>64</td><td>true</td></tr><tr><td>steps</td><td><code>integer</code></td><td>Steps for sampler to step whle sampling</td><td>25</td><td>true</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>true</td></tr><tr><td>sampler</td><td><code>string</code></td><td>Sampler for diffusion model inference</td><td>DPM++ 2M</td><td>true</td></tr><tr><td>height</td><td><code>integer</code></td><td>Height of the generated images</td><td>512</td><td>true</td></tr><tr><td>width</td><td><code>integer</code></td><td>Width of the generated images</td><td>512</td><td>true</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>true</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/7758545/202405220201/6ee8737899794e9bb2e12b5844a4b11a.jpg"
}
```

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

### Inpaint with ControlNet

<mark style="color:green;">`action`</mark> `img2img`

**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>action</td><td><code>string</code></td><td>The action of ControlNet, txt2img or img2img</td><td>txt2img</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>controlnet_model</td><td><code>string</code></td><td>The ControlNet model id from civitai. How to get it? Click on a model page on civitai, and copy the series number within the download link.</td><td>10971</td><td>true</td></tr><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>no_mask</td><td><code>boolean</code></td><td>Whether to use mask</td><td>False</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>false</td></tr><tr><td>prompt</td><td><code>string</code></td><td>The text prompt for ControlNet. 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 ControlNet.</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>true</td></tr><tr><td>controlnet_module</td><td><code>string</code></td><td>The ControNet module</td><td>none</td><td>true</td></tr><tr><td>guidance_start</td><td><code>number</code></td><td>ControlNet guidance start</td><td>0</td><td>true</td></tr><tr><td>guidance_end</td><td><code>number</code></td><td>ControlNet guidance end</td><td>1</td><td>true</td></tr><tr><td>control_mode</td><td><code>string</code></td><td>The improved guess mode</td><td>Balanced</td><td>true</td></tr><tr><td>weight</td><td><code>number</code></td><td>The weight of the controlnet model</td><td>1</td><td>true</td></tr><tr><td>resize_mode</td><td><code>string</code></td><td>Four modes for output shape calculation: (1) Keep: keep original shape, (2) Certain: based on input width/length (divisible by 32), (3,4) min/max ratio: keep aspect ratio, the resize factor is the min/max of (h/H, w/W).</td><td>certain</td><td>true</td></tr><tr><td>threshold_a</td><td><code>integer</code></td><td>The threshold A for controlnet model</td><td>64</td><td>true</td></tr><tr><td>threshold_b</td><td><code>integer</code></td><td>The threshold B for controlnet model</td><td>64</td><td>true</td></tr><tr><td>steps</td><td><code>integer</code></td><td>Steps for sampler to step whle sampling</td><td>25</td><td>true</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>true</td></tr><tr><td>sampler</td><td><code>string</code></td><td>Sampler for diffusion model inference</td><td>DPM++ 2M</td><td>true</td></tr><tr><td>height</td><td><code>integer</code></td><td>Height of the generated images</td><td>512</td><td>true</td></tr><tr><td>width</td><td><code>integer</code></td><td>Width of the generated images</td><td>512</td><td>true</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>true</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>true</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>true</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>true</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>true</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/7758545/202405221652/f9550811186e4152952020ea097375d6.jpg"
}
```

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


---

# 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://docs.myshell.ai/ko/create/pro-config-mode/api-reference/widgets/56-controlnet-with-civitai.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.
