# IMG2IMG+Partial Repainting

## **Basic Image to Image**

Img to Img can be adjusted based on [Text to Image](/guide-1/2-seaart-ai-basic-function/2-10-workflow/text-to-image-workflow.md), adding the "Load Image" and "VAE Encode" nodes.

Since the input image is just a pixel image, it can't be directly placed into the latent space. Therefore, it requires a VAE encoder to encode the image so that the latent space can recognize it. Here, the final generated image size is consistent with the original image.

**Empty Latent Image:** The previous Text to Image must denoise through Empty Latent Image before generating a new image. Now that an image has been added, the Empty Latent Image is no longer needed.

**Workflow:** Upload an Image → Select Models → Enter Prompts → Adjust Parameters → Generate.

**Parameters:**

denoise: Equivalent to Denoising Strength, can be adjusted between 0-1.

Using Img2Img allows for changing styles, repairing images, extending images, high-definition restoration, etc.

**Pre-processing Image**

You can scale or crop the image by adding different nodes, or choose not to add any.&#x20;

**Upscale Image/Upscale Image By:** Upscale the image.&#x20;

**ImageCrop:** Crop the image.

## **Partial Repainting**

Four Methods: VAE Encode (for Inpainting), Set Latent Noise Mask, ControlNet Inpaint, and CLIPSeg.

1. **VAE Encode (for Inpainting)**

Add VAE Encode (for Inpainting), connect Mask, right-click on the image, and select Open in MaskEditor to draw a mask. If there are issues with a section of the drawn mask, you can erase it by holding down the right mouse button.

**Workflow:** Choose a model similar to the original image, and enter prompts for the masked part.

**VAE Encode (for Inpainting):** Equivalent to repainting, with higher randomness, and the original masked area will not be preserved.

2. **Set Latent Noise Mask**

First, encode the image through VAE to turn it into content recognizable by the latent space, then regenerate the masked area as noise content.&#x20;

Set Latent Noise Mask: It will refer to the original image for repainting, ensuring a better understanding of the generated content, with a lower probability of generating incorrect images, thus suitable for fine-tuning while maintaining similarity to the original image.

3. **ControlNet Inpaint**

Add the ControlNet, select the Inpaint model, and preprocess the image accordingly (Inpaint Preprocessor).&#x20;

<mark style="color:red;">Note:</mark> Don't forget to add the VAE encoder so the image can enter the latent space.

4. **CLIPSeg**

Enter prompts to automatically divide the mask areas, eliminating the need for manual paint-over. It can be used together with Set Latent Noise Mask.

**Parameters:**

text: Input the area you want to repaint.

threshold: The precision level of content recognition.

dilation\_factor: The diffusion degree of content recognition.

**Output:**

Heatmap Mask: Heatmap image.

BW Mask: Black and white image.

You can preview the recognized mask areas separately.

**Differences between the four repainting methods:**

1\. VAE Encode (for Inpainting): Equivalent to erasing and repainting with higher randomness, suitable for generation from scratch.

2\. Set Latent Noise Mask: It will refer to the original image for repainting, ensuring a certain similarity to the original image, suitable for fine-tuning.

3\. ControlNet Inpaint: Relatively stable and refined.

4\. CLIPSeg: Automatically recognizes the mask areas, so there's no need for manual paint-over, making it more convenient.


---

# 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.seaart.ai/guide-1/2-seaart-ai-basic-function/2-10-workflow/img2img+partial-repainting.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.
