# Stable Diffusion Upscale

## Try it in the Widget Center

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

## Usage

Scale up the original image to the specified shape. You can opt to restore the face within the image by increasing the visibility of GFPGAN and Codeformer.

**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>resize_mode</td><td><code>integer</code></td><td>Sets the resize mode: 0 to upscale by upscaling_resize amount, 1 to upscale up to upscaling_resize_h x upscaling_resize_w.</td><td>0</td><td>false</td></tr><tr><td>gfpgan_visibility</td><td><code>number</code></td><td>Sets the visibility of GFPGAN, values should be between 0 and 1. Use for face restoring</td><td>0</td><td>false</td></tr><tr><td>codeformer_visibility</td><td><code>number</code></td><td>Sets the visibility of CodeFormer, values should be between 0 and 1. Use for face restoring</td><td>0</td><td>false</td></tr><tr><td>codeformer_weight</td><td><code>number</code></td><td>Sets the weight of CodeFormer, values should be between 0 and 1. Use for face restoring</td><td>0</td><td>false</td></tr><tr><td>upscaling_resize_ratio</td><td><code>number</code></td><td>By how much to upscale the image, only used when resize_mode=0.</td><td>2</td><td>false</td></tr><tr><td>upscaling_resize_w</td><td><code>integer</code></td><td>Target width for the upscaler to hit. Only used when resize_mode=1.</td><td>512</td><td>false</td></tr><tr><td>upscaling_resize_h</td><td><code>integer</code></td><td>Target height for the upscaler to hit. Only used when resize_mode=1.</td><td>512</td><td>false</td></tr><tr><td>upscaler_1</td><td><code>string</code></td><td>The name of the main upscaler to use</td><td>ESRGAN_4x</td><td>false</td></tr><tr><td>upscaler_2</td><td><code>string</code></td><td>The name of the secondary upscaler to use. Set to 'None' for quick upscale. The result will be a fusion of two model, decided by `extras_upscaler_2_visibility`.</td><td>None</td><td>false</td></tr><tr><td>extras_upscaler_2_visibility</td><td><code>number</code></td><td>Sets the visibility of secondary upscaler, values should be between 0 and 1.</td><td>0</td><td>false</td></tr><tr><td>upscale_first</td><td><code>boolean</code></td><td>Should the upscaler run before restoring faces?</td><td>False</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/29381f8ee23144a69e88a64fa8232fca.jpg"
}
```

{% endcode %}
{% endtab %}

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

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

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

## Detailed Guidelines

* **Upscale (SuperResolution)**
  * Main parameter:
    * `image` : The input image, can be a url or base64 sting. Any size
    * `resize_mode`: Sets the resize mode: 0 to upscale by upscaling\_resize amount, 1 to upscale up to upscaling\_resize\_h x upscaling\_resize\_w.
    * `upscaling_resize_ratio` : By how much to upscale the image, only used when resize\_mode=0.
    * `upscaling_resize_w & upscaling_resize_h`: Target width/height for the upscaler to hit. Only used when resize\_mode=1. Change the ratio of with/height will casuing a center crop of generated images
    * `upscaler_1` : The name of the main upscaler to use, choose `["None", "Lanczos", "Nearest", "ESRGAN_4x", "LDSR", "R-ESRGAN 4x+", "R-ESRGAN 4x+ Anime6B", "ScuNET GAN", "ScuNET PSNR", "SwinIR 4x"]`
    * `upscaler_2`: The name of the secondary upscaler to use. Set to 'None' to disable. The result will be a fusion of two model, decided by `extras_upscaler_2_visibility`
    * `extras_upscaler_2_visibility`: Sets the visibility of secondary upscaler, values should be between 0 and 1. The result will be `final = (1-α) image_a + α image_b`
  * Other functional parameter:
    * `gfpgan_visibility` : Sets the visibility of GFPGAN, values should be between 0 and 1. Use for face restoring. 0 for disabled. The result will be a fusion addition
    * `codeformer_visibility && codeformer_weight` : Sets the visibility and weight of CodeFormer, values should be between 0 and 1. Use for face restoring. The result will be a fusion addition
    * `upscale_first` : Should the upscaler run before restoring faces? default to False


---

# 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/27-stable-diffusion-upscale.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.
