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.