-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDXL InPainting: Mask blur option is negated by forced binarization. #10690
Comments
The binarization should happen before the blur effect is applied, right? At the end of the day, this is free open source software so I have no expectations. Thanks a lot, you guys are awesome. |
Hi, there's a confusion that probably we will need to fix in the docs if it's not clear. The blur for the image mask is used when the inpainted part is pasted back in the original image, so going step by step: First the mask is converted with the image proccesor into another variable called diffusers/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py Lines 1449 to 1451 in aad69ac
After that, the inpainting pipeline uses the Finally, at the end, if the user passed a diffusers/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py Lines 1731 to 1732 in aad69ac
Here's the apply_overlay function if you want to read it.
Since the blur can be done by the user and we always need a binary mask for the inpainting we do the binarize always to prevent errors. We're working on a modular diffusers system where you will be able to do what you're asking though, so if you wait a little longer and insist on doing this on your side, you will be able to build a custom pipeline with whatever you want. In the meantime, if you want to use gradient masks (soft inpainting) you can use differential-diffusion that actually works with what you want.
Even if you don't have expectations, please don't hesitate to open issues if something doesn't work or if you see errors in the code, we will fix it if it's something we missed and we try to always answer the questions. |
The SDXL InPainting pipeline's documentation suggests using
pipeline.mask_processor.blur()
for creating soft masks, but this functionality is effectively broken due to the implementation order. Please let me know if I'm missing something here. Based on my testing, whether I use a blurred mask or blur them with the built in method, they still show a solid seam as if there was no blur applied.The mask processor is initialized with forced binarization:
When processing masks, any blur effect is applied before binarization, which then converts all values back to pure black and white, completely negating the blur effect (if I'm not mistaken). The VaeImageProcessor defaults binarize to false, but when masks are initialized it sets binarize to true.
Relevant files:
diffusers/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py[326]
diffusers/image_processor.py[88][276][523]
Reproduction
Inpaint pipeline config using either your own blurred image or the built in blur method according to documentation. It's fairly self explanatory and I don't have a minimal script to share.
System Info
diffusers==0.32.2
Who can help?
@yiyixuxu @DN6
The text was updated successfully, but these errors were encountered: