Repaint part of an image Inpainting

Paint over the part you want changed and leave the rest of the image exactly as it was.

Same lesson, three subjects

Step by step

Skill level
  1. Source image

    1 · Attach the picture to patch

    changes part of a picture and leaves the rest exactly as it was, so it needs a picture to start from.Open and attach the one you want to change. The example used the text-to-image result, scaled down to 512×512.The picture is yours to attach; nothing on this step comes from the example.
  2. Source image

    2 · Set the mode to Inpainting

    Press Inpainting in the mode row. Two things change:
    • A brush appears over the preview, so you can paint the part you want redrawn.
    • The request goes down the inpainting path rather than the img2img one.
  3. Source image

    3 · Paint the mask

    Paint over everything you want redrawn, and nothing else: whatever you leave unpainted comes back untouched.Brush size sets the nib, and the eraser takes paint back off. What you paint is sent alongside the picture as a black-and-white mask the same size as it, and only the white part is drawn into.A generous mask with a soft edge usually blends better than a tight one. The mask is drawn rather than typed, so it is yours to make.
  4. Prompt

    4 · Prompt for the patch alone

    Describe what should fill the region you painted, not the whole picture. The model only draws inside the mask, so words about the rest of the image do nothing.An inpainting model tends to continue whatever surrounds the masked area, so a masked patch of sky usually comes back as more sky. To get something else there, weight the words that describe it.That is why the subject here is written as (a phrase:1.4), which is at work: it makes the model paint what you asked for instead of what was there.This example asked for (a colossal steampunk zeppelin airship:1.4) seen from below, filling the sky, red and gold painted hull, brass gondola with rows of glowing round windows, spinning propellers, mooring ropes, dramatically close overhead, with lowres, blurry, watermark, text, empty sky, plain sky, clouds only, ocean, sea, water surface, sailing ship, boat, cruise ship in the negative prompt.
  5. Model & style

    5 · Pick an inpainting model

    An inpainting model is trained to blend a repaint into what surrounds it; an ordinary model tends to leave a visible patch instead.This example used Deliberate Inpainting at 512×512, the size of the source, and the two are set together. Every inpainting model the horde serves is a Stable Diffusion 1.5 one, which is why the size is what it is.There is no strength slider in this mode: the masked region is replaced outright rather than nudged.
  6. 6 · Send it to the horde

    Press Generate. Only the masked region comes back changed.When it lands, look along the edge of where you painted. A faint seam there is normal, and it is the usual reason to paint a more generous mask next time.Expect anything from a few seconds to a few minutes. This run took about 9 seconds.

Where next

You can now change one part of a picture and leave the rest alone. The other thing a picture can lend you is its shape: ControlNet keeps the composition of a picture and lets the prompt change everything else about it.