[Stable Diffusion] Explain how to use img2img to generate images from images!

 txt2img is the mainstream for creating illustrations with Stable Diffusion, but it's not easy to create the illustrations you want because the original is text.

[Stable Diffusion] Explain how to use img2img to generate images from images!

[Stable Diffusion] Explain how to use img2img to generate images from images!
[Stable Diffusion] Explain how to use img2img to generate images from images!

img2img solves such problems. In addition to prompet, new illustrations are generated based on existing images, so you can specify more nuances.

In this article, I'll explain these : 

  • [Stable Diffusion] Advantages of img2img to generate images from images
  • Explain how to use img2img
  • Verify the difference between the 4 Resize modes that can be selected with img 2 img!
  • Partial image correction is also possible with the paint function in img2img!
  • If you want to generate illustrations more smoothly...
  • How to easily manage a large number of generated illustrations
so that by the end you'll know how to use img2img to get the illustration you want.

If you are a beginner or have any questions about Stable Diffusion, please read the following articles. It explains in detail how to download and use Stable Diffusion.

[Stable Diffusion] Three advantages of img2img for generating images from images :

[Stable Diffusion] Three advantages of img2img for generating images from images
[Stable Diffusion] Three advantages of img2img for generating images from images

The advantages of using img2img with Stable Diffusion are the following three.

  • Can give detailed instructions for Stable Diffusion
  • Less sampling steps than txt2img
  • The composition is difficult to collapse even at a large size
I will explain in order.

Can give detailed instructions for Stable Diffusion

img2img allows you to give Stable Diffusion more detailed and specific instructions than txt2img.

For example, when you receive a request to create an illustration

"A girl is standing," "pointing her index finger," "the background is the ocean," "the sky is clear," etc.

Even if you draw an illustration with your own understanding, it may be far from the client's image.

Can give detailed instructions for Stable Diffusion
Can give detailed instructions for Stable Diffusion
Don't you think it would be very easy to understand if you were instructed to "draw like this" based on the image?

The amount of information that can be conveyed by text and images is incomparable. Img2img, which can give instructions based on images, can tell Stable Diffusion exactly what you want.

Less sampling steps than txt2img

When generating illustrations with img2img, quality can be maintained even with fewer sampling steps than with txt 2 img.

Sampling steps are the "number of times to remove noise" when Stable Diffusion generates an illustration.

The lower the number, the rougher the noise removal (more precisely, the larger the truncation error when removing noise), and the lower the quality of the resulting illustration.

On the other hand, it is annoying that the more sampling steps, the more time it takes to generate an illustration. It is a state of balancing work time and quality.

The strength of img2img is that it can generate high-quality illustrations with fewer sampling steps than txt2img.

Because it is based on an existing image, it is easier to finish the work than txt2img, which has to draw an illustration from scratch.

It's not "order of magnitude faster", but it's nice to be able to save time even a little.

The sampling steps are explained in detail in the following article.


The composition is difficult to collapse even at a large size

One of the attractions of img2img is that the composition is less likely to collapse than txt2img.

In txt2img, if you try to generate an illustration with a large size from the beginning
The composition is difficult to collapse even at a large size
The composition is difficult to collapse even at a large size

I often end up with an incomprehensible picture like this. This is due to the fact that the model is originally learning with a size of 512 × 512, so it is not good at drawing high-quality illustrations.

However, img2img has a high probability of generating illustrations without failure even in large sizes. No matter how bad I am at it, it's hard to get a crazy composition because it's based on an image.

Explain how to use img2img :

Explain how to use img2img
Explain how to use img2img

Let's actually generate an illustration with img2img.

When you select the img2img tab, such an operation screen will be displayed. Many items are the same as txt2img.
img2img
img2img 

First of all, let's throw in a suitable image. If you press the "Generate" button with all the settings as they are
prompts
prompts

This illustration was generated. Well, I feel like I'm grasping the atmosphere.

Next, let's use spells (prompts) together to improve the quality of this illustration :
  • Prompt: best quality, masterpiece, Paddy field
  • Negative prompts: worst quality, low quality,
I will try to put a quality up spell like this. "Paddy field" is a rice paddy. I put it in because it was often considered a grassland.

Negative prompts
Negative prompts

he quality of the illustrations has improved since then.

The basic usage of img2img is to get closer to the ideal illustration by using the original image and spells like this.


Of course, if you change the model, the pattern will change, so please try various combinations.

Pay attention to the denoising strength value

When generating illustrations with img2img, pay attention to the denoising strength value :
  • Low denoising strength: draw respecting the original image
  • High denoising strength: draw freely
It has the following features. I don't think it's very clear if it's written, so let's look at the illustration when actually changing the denoising strength.

Denoising strength: I have the impression that the degree of freedom increases from around 0.6. At 0.9 and 1.0, you can see that the original image is mostly ignored and drawn freely.

Since there is no correct answer, it is best to decide based on how strongly you want to make use of the original image.

Verify the difference between the 4 Resize modes that can be selected with img2img!

Verify the difference between the 4 Resize modes that can be selected with img2img!
Verify the difference between the 4 Resize modes that can be selected with img2img!
On the img2img operation screen :
  • Just resize
  • Crop and resize
  • Resize and fill
  • Just resize (latent upscale)
You can choose between these Resize modes.

If you want to change the aspect ratio of the original image, the generated result will differ greatly depending on the Resize mode, so you should choose carefully.

For a detailed explanation of Resize mode, please read the following article.

Partial image correction is also possible with the paint function in img2img!

Partial image correction is also possible with the paint function in img2img!
Partial image correction is also possible with the paint function in img2img!

img2img has a useful function called "in paint". By using Inpainting, it is possible to partially modify the illustration.

"I like the composition, but my fingers aren't right..."

How to use Inpainting is explained in detail in the following article.

Next Post Previous Post
No Comment
Add Comment
comment url