How I inpaint: A beginners guide to img2img


Updated:

How I inpaint: A beginners guide to img2img

A step-by-step guide on how to use img2img.

Warning: This guide is based on SDXL, results on other models will vary.

This guide REQUIRES a basic understanding of image generation, read my guide "How I art: A beginners guide" for basic understanding of image generation (For further improve your results, reading "How I ControlNet" is also recommended but not mandatory).

Step 1. Creating a starting point.

Img2Img is a process in which the AI takes a provided image and re-imagines it with the help of the provided prompt. This can be used for many porpuses and each porpuse requires it's own workflow; therefore this will only be ONE of many ways to use img2img.

For this guide I will be using this image:

This may seem like an already good image, but not for me!

If you are using tensor.art for your generations, you will use the txt2img tab (if you are generating images) and the Img2Img tab. All settings you should already understand if you read the "How I art: A beginners guide" guide. Anything NOT mentioned there I will explain here.
In my case I will be using Re-forge; but don't worry, the logic is the same.

For the sake of context; this is how my screen looks.

Step 2. Editing tools

Once you have your base image; it's time to edit in the changes you want. Maybe you generated something, or saw a cool YCH you want to recolor/edit. No matter the origin, you need to add in any missing details yourself.
This is the easiest way and most reliable too.

I use photoshop; so, here's my desired edits:

Not much, just fixed my fursona's colours and removed the paints in the background, most of the other things will be managed by the AI anyways (Colour correction also goes a long way).

Step 3. The prompt and you

Now that your starting image is as close as possible to the way you want it to look it's time to prompt it. But, instead of prompting what we want, we prompt what we see.

The way img2img works is that; when you show it an image, it will try to recreate it using your prompt as a guide. So if the image it's a dog with an apple and you prompt for a cat in a megazord; the image will come out looking like a mush slop. Just use txt2img in that case.

Depending on what platform you are using; take the starting image and upload it to the img2img tab.

"But Arturo!" I hear you say. "Isn't this an inpainting guide? Shouldn't we use the inpaint tab?"

And you are correct, to inpaint, you use the inpaint tab, but to know how to inpaint you must learn how to img2img first. Apply wax; remove wax my grasshopper.

Don't forget the fitting prompt!

Now that you have your promt and your image, we must learn the settings:

Regardless of your platform of choice, you will have a Sampling method, a Schedule type, Sampling steps, etc. So go ahead and set them up accordingly to your model, image, and prompt.

As for the img2img exclusive settings:

"Just resize", "crop and resize", "resize and fill" and "just resize (latent upscale)".

Be a darling and don't touch that for now. This is a beginners guide after all.
Basically; these change how the result image will interact with the original image. If your starting image is portrait but you want landscape, resize will stretch the image to meet the "Resize to" resolution. Crop and resize will go to the center of the image, crop the aspect ratio and resize that area only; resize and fill will keep the aspect ratio and try to fill in the voids and Just resize (latent upscale) will do the same as the first option; but with latent upscale.

"Refiner"

This triggers a checkpoint change during the img2img process, for example, if you use ChromaXL and Refine with Kiwimixv3; then activate it and select said checkpoint, set up the % and you are done. The % means that, if set at 80% for example, the checkpoint change will trigger after the 80% progress has been done.

If you use 100 steps, the checkpoint will change at step 80; for example.

"Resize to" and "Resize by"

Resize to means your result image size will adapt to whatever resolution you set there. So if the image is 800*800 and you set 80*1000; depending on the Resize mode, the resulting image will aim for that ratio.
Resize by goes by ratios, so of your image is 1024*1024 and you set it to 2, the result image will be 2048*2048!

Note: If your image is too small, opt for resize by and up the ratio as far as your platform or computer lets you. In my case the max res I can work with is 2048* so anything bigger and I run out of memory.

In my case the image is 2048* so I don't need to change anything there.

"Batch count/size"

Same as with any generation mode; count is for how many images you want to generate in total, and size for how many images you want to generate at the same time. For img2img I recommend a count of 4 or more depending on complexity, this means I will get 4 images total to pick the best from.

"CFG Scale"

Same as with any generation mode; the guidance strenght. Change accordingly to your model's settings.

"Denoising strength"

This one is your cream de la cream. The higher the number the more creative freedom the model will take. Also the hardest setting to get right in ANY given moment.

For example; lighting models work fast as hell, so even a low denoise can dramatically alter the results, while average models will need higher denoise to do something. ChromaXL is a lighting model, so if I go over 0.3 or 0.4; I risk getting abnormal results.

Unfortunately there is no "defenitive" guide for denoise strength, but as you test and play with this tab you will eventually learn the "feel" and no longer struggle. Trust me.

FOR TENSOR.AI USERS:

Tensor.AI offers less options in terms of settings, so for an abridged version; add your starting image; select the model you want, set the desired denoise stregth, set the desired resolution px*px and the rest you should already understand. If you have any questions; please leave a comment.

Step 4. Go gambling!

Keep your seed random and click generate! Test different denoise levels, change the prompt if something's odd. As you test and tweak you will notice the new image make more and more sense.

And that's it!

Congratulations, now you know the basics of inpainting and img2img. Next time you will learn how to use the sketch tab, inpaint tab and more!

5
0