-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Fix Gradient Mask (Canvas) Inpaint Model Support #6205
Fix Gradient Mask (Canvas) Inpaint Model Support #6205
Conversation
Think it's the right decision to not overinvest in making inpainting optimized for speed, given these models are rarely used. The extra time seems worthwhile |
The optimization is not for inpainting models. It's for all other models. Because inpaint models require the extra VAE encode, we are performing that encode on all other models that don't require it. But right now we do not have a clean way of distinguishing between the two without an extra unet model load anyway. So with this we lose a little bit of speed on all masked canvas operations, but we enable inpaint models to work again like they did before. |
In a discord conversation we discovered that during the MM2 refactor I had inadvertently removed the model variant enum from the diffusers model configs. The values were Normal (4 in-channels), Depth (5 in-channels, SD2.x only), Inpaint (9 in-channels). To fix this:
Then I believe the changes int his PR could be much simpler. Users with diffusers inpainting models installed before this fix is rolled out will have incorrectly-configured models. Here are a few ideas to fix existing models:
|
Even with that, we would still need the changes in this PR (as they currently are) which allow the gradient mask node to produce a masked_latents. If we add support for a quick Unet variant check, then we can add a unet field and only encode when necessary. Right now this PR matches how we previously supported inpaint models prior to 4.0 but now with gradient mask node. |
shoulda been here all along
Also simplify the layouting for all model view/edit components.
a76b730
to
07e4529
Compare
Special handling for inpainting models
@dunkeroni Gotcha, thanks for clarifying that. I've updated this PR:
Think we are good to go! |
Summary
Adds VAE and Image fields to the Create Gradient Mask node so that it can make a masked_latents tensor for inpaint models. Canvas inpaint/outpaint graphs are updated to include the new connections.
This behavior matches what the older Create Denoise Mask node did as well.
Related Issues / Discussions
Closes #5972
We've had some back and forth on using the UnetField to check for inpainting type and skip this encode process when it is not needed, but we need a reliable way to test for that on all model formats without loading the model itself (currently it is done by checking the in_channels number). If we come up with a standardized way to query this quality of the model, then we can add that and shave off a bit of time for canvas operations.
QA Instructions
Please test in Canvas interface, inpainting and outpainting. The inpaint models I have tried work, but we have seen in the past that some don't always behave like the others. Sometimes having a bit of edge_size on the coherence settings helps remove edge line artifacts, sometimes it creates different edge artifacts depending on the mask shape. For best results, start at zero and increase to 16 if necessary.
Checklist