Is it possible to inpaint only the masked area?

Screenshot from 2023-05-17 16-41-34
Hi all!
In the stable-diffusion-ui there is an option to select if we want to inpaint the whole picture or only the selected area. It means that its guaranteed that the rest of the image will stay the same
Is there something analogous on StableDiffusionInpaintPipeline?

thanks

Unless I’m mistaken, this is how the inpaint pipeline works? Or at least the IF inpaint pipeline works this way. Could you provide a code snippet?

In Stable Diffusion, “Inpaint Area” changes which part of the image is inpainted. If you use whole picture, this will change only the masked part while considering the rest of the image as a reference, while if you click on “Only Masked” only that part of the image will be recreated, only the part you masked will be referenced.
This article and this github discussion reference pages elaborates it. I myself trying to implement that feature using diffusers, finding it hard.

P.S. This reddit thread also elaborates.

Same here… do you find any solution? I am stucked

Did this issue ever get solved?

Since this is one of top results in searching for this subject using automation 1111 keywords, for anyone coming to this old post from the search results:
This is implemented in diffusers library. You only need to add your desired padding by padding_mask_crop parameter to get the same effect as “Only masked” area inpainting:

result= pipe('prompt', image=image, mask_image=mask_image, strength=0.75,generator=generator, padding_mask_crop=32)

More info and example here.

1 Like

I have just given it a try this morning but it does not seem to work