
How I inpaint: A beginners guide to img2img inpainting
A step-by-step guide on how to use the inpaint tab on tensor/Reforge/A1111/etc.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.Inpainting 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 it.For this guide I will be using this image:How I got it? First I made my prompt, fished a good seed, hires.fix'ed it to 2.5 the original resolution for extra details and then using photoshop I shrank it back down to the original resolution once I noticed I had to inpaint it.This image looks ALMOST perfect, but if you notice, the feet have an extra finger.And that's a nono.The ears of Arturo are also wrong, the nuzzle pattern is wrong... SO MANY ERRORS! Thankfully we got inpainting!Step 2. Editing tools and maskingInpainting is like img2img but in a more "targeted" approach. It only targets a section fo the image and changes it, instead of the whole thing like a regular img2img pass. But how does it work?It works via "masking". This is similar to masking on photoshop, the white area is deleted and the black area is shown; well here the white area is modified and the black area is kept intact.On WebUIs like reforge, your mask is shown as the white semitransparent brush. You cover the area you want to change.On tensor the UI is similar but the mask is shown separately:The white is the area I want to modify, and the black is the area I want to leave as is.TIP: Change one thing at a time. It's slower but nets you way better results.Drawing over the image like in the guide: "How I inpaint: A beginners guide to img2img" is also recommended for certain fixes.For example:I drew over some things to fix my face.So tldr; grab the image to fix, draw on the missing details if you can, else add it to the inpaint tab and mask one detail at a time. Do not try to fix everything on a single run!Step 3. The prompt, the mask and you.Now that your image is as close as possible to the way you want it to look, it's time to modify your prompt.As I said before, inpainting only looks at the masked area and the close regions around it. You can modify this settings on some WebUI but not on tensor. This means that it is wise to only prompt what you are masking and what surounds it. So if my prompt is:"masterpiece, best quality, [[by moki \(artist\):by dr.kiyo:0.33]:by nekowuwu:0.66], sex, duo, male/female, vaginal penetration, detailed background, cum in pussy, (balls deep), missionary position BREAK awff, anthro, male, shirt, pants, black fur, grey fur, reverse countershading, black countershading, black ears, wolf, standing, red eyes, orgasm face, saliva string, looking down BREAK rory mercury, black dress, black hair, blunt bangs, bow, frilled bow, frilled dress, frills, hair bow, long hair, necktie, puffy short sleeves, puffy sleeves, red dress, red eyes, red necktie, short sleeves, smug smile, nipples, huge knot, saliva string, red eyes, looking up"And im fixing the ears, I can shrink it to:"masterpiece, best quality, [[by moki \(artist\):by dr.kiyo:0.33]:by nekowuwu:0.66], duo, male/female, BREAK awff, anthro, male, black ears, wolf, red eyes, orgasm face, saliva string, looking down BREAK rory mercury, saliva string, red eyes, looking up"You modify the prompt accordingly to the masked area!Step 4. Denoise, your best friend. Your worst enemy.Like on regular img2img, denoise strength changes how much the image will deviate from the original. This can work both ways:Too weak: Minor to net zero changesToo strong: A completely new imageStrong denoise is great if you want to add things to the image; let's say you wanted the wall to have a framed picture. You can mask an area of the wall, turn up the denoise and make your promt around the framed picture.Weak denoise is great if you want to add details; let's say you like the position of the fingers, but it didn't gen the nails. You can try your luck with a low denoise and turn it up until the nails appear; then re-run that strength as many times as you need to get the perfect nails!See how I wanted to remove the door knob from the wall? I used high denoise on it and ran it on batch 4. 3 out of 4 removed it, one changed it to a switch.Settings:These are from ReForge, but the logic is the same on any platform. You want to use the following on ANY inpainting you do unless necessary (Yes, sometimes you do need to play with these too).*Just resize*Inpaint masked*Original*Only Masked VERY IMPORTANT*Only masked padding, pixels: 80-124Step 5. PaddingYes, this one gets it's own step.Padding is how much the AI sees outside the masked areas. The more pixels you give it the more of the image it can see to inspire itself on what and how to change things. Remember when I resized the image to the original resolution?Because inpainting does a new image at the set resolution (like 1024*1024), it then resizes it to fit on the original image. This means that if you inpaint at 2048*2048 on a 1024*1024 image, the inpaint result will then shrink to 1024, this is AMAZING for adding small details –and it's why padding matters. The more pixels you give padding the lesser this effect will take effect.BUT, it is also great for complex inpainting to give it a larger padding, because it can sometimes confuse itself with the prompt and try to add things it thinks they are missing. Let's say you forgot to remove "penis", and the masked area has no penis on it even after padding; the result image will most likely try to add a penis. But if padding is large enough it sees the penis outside the mask then it won't try and do a new penis!Here the red is with little padding (only sees the ears) vs more padding (now it shows the eyes and nuzzle, improving context of where to aim the ears towards).Unfortunately Tensor does not have any of this and only has mask blur...Step 6. Mask blurMask blur is the "blur" or "ghosting" outside the mask you allow the AI to change. Meaning that even after masking, you can let the AI leak outside the masked area through blur, this is great to blend in small details from inside and outside the mask, but can also alter things you don't want to change. Reducing the blur will make the masked area more noticeable due to the lack of blending but will leave intact the outside region of the mask (based on how many pixels you gave it).Step 7. Go gambling!Now, just like before. 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 as you fix one detail at a time, you will soon end up with your perfect image!to:
