2025년 3월 3일 월요일

4-1 Let's figure out what you can do with img2img(Stable Diffusion Practical Guide Table of Contents)

>>>What is image-to-image?

So far, we have experienced txt2img, commonly known as 'image creation from text'. From now on, we will learn image-toimage, a method of creating a new image based on an image. It can register and output detailed atmospheres, expressions, postures, complex expressions, and color combinations that are difficult to convey with language alone. It is also helpful when modifying or finishing images created with txt2img so far.

img2img does not use a prompt written in language to assign UNet conditions, but rather assigns an image and processes it, and is also called an 'image prompt'. Rather than assigning conditions to the latent space in a language converted from CLIP, it inputs another image that is similar in size, layout, color, etc. to the image you are thinking of and instructs 're-drawing'.

This is similar to 'ControlNet', which will be introduced in the next chapter. However, while ControlNet sets the conditions for the generated image using 'image understanding' from the computer's perspective, img2img specifies the target image and mask as images. Therefore, it is a powerful image control method that processes internal processing with a noise removal method using latent diffusion and controls the processing target of the final image on a pixel basis. Also, if the denoising strength is set to 0.5 or less, an image can be generated without significantly deviating from the original image.

This article explains img2img used in SDXL.

SDXL is a UNet that is about 3 times larger, and its visual fidelity has been improved, and it has also been learned in relation to sizes other than square images such as 512x512 or 1024x1024.

>>>Let's use the img2img function

To use img2img, click on the img2img tab in the WebUI. img2img has six functions: img2img, Sketch, inpaint, inpaint sketch, inpaint upload, and Batch. You can use each function by selecting the tab. Chapter 4 explains the typical usage of img2img, Sketch, and Inpaint in order.

>>>Let's create an image using img2img.

img2img is a function that creates a new image based on an input image and a prompt. You can upload an image by dragging and dropping it into the display area on the WebUI, or by clicking inside the area to open a window and selecting it directly from a folder.

REsize mode, Resize to, Resize by, and Denosing strength are added to the txt2img parameters set in the WebUI. They are also the same as the img2img function.

1.Resize mode

When the size of the input image and the image to be created are different, choose a method to compensate for the difference. Let's choose an appropriate method according to the purpose. The table below shows how to change the width of the image to be created from 512pixels to 720pixels, which is the same as the height, depending on the method.

▲Original image

Resie mode

Just resize

Crop and resize

Resize and fill

Just resize
(latent upscaler)

Complementary method

The aspect ratio of the input image is adjusted to match the size of the image to be generated.

Maintains the aspect ratio of the input image and crops and enlarges a portion to fit the size of the generated image.

Maintains the aspect ratio of the input image and compensates for any missing parts by copying corner pixels.

Like just resize, it ignores the aspect ratio of the input image, increases the size of the image to be generated, and uses a latent upscaler.

Example of supplementary results

Run Resize mode and wait a bit, and the GPU fan will spin vigorously. As you read this article, you will realize the capabilities of the GPU. This is the moment when you feel why a high-performance GPU is necessary. HAHAHA.

2. Resize to/Resize by

Specify the size of the image to be created with img2img. You can specify the width and height sizes in the Resize to tab, and if you select Resize by, you can specify the scale to enlarge or reduce while maintaining the width and height ratio of the input image.

3.Denoising strength

Sets how close the generated image will be to the original image.

>>>Let's learn about denoising strength

Denoising strength refers to specifying the strength of random noise to be added to the input image. The initial value is 0.75, and the closer it is to 0, the less noise to be added, so it faithfully follows the characteristics of the input image. The closer it is to 1, the more noise is added, and the more the characteristics are lost, so an image completely different from the input image is generated.

If you compare the generated images by changing the Denoising value with the X/Y/X plot, you can see that the generated image when Denoising is 0.3 is almost the same as the input image, but the generated image when Denoising is 0.8 has completely different clothing, hair color, and background conditions. In this way, you can adjust the size of the change compared to the input image by using the Denoising value.

Denoising: 0.3

Denoising: 0.6

Denoising:0.7

Denoising:0.8

Let's try a setting that suppresses color changes.

Since img2img generates a new image by adding noise to the input image, the color of the generated image may change slightly when you run img2img. You can prevent this color change by selecting the correction option. Click img2img in the Settings tab to select it. You can turn on the correction function by selecting Apply color correction to img2img results to match original colors. This will perform color correction based on the input image.


구글 keep에 메모하기




댓글 없음:

댓글 쓰기

Recommended Posts

Love is taking responsibility till the end

  I created a campaign called "Don't Abandon Your Beloved Dog" with Stable Diffusion. I tried creating it several times, but i...