Conversation
Assisted-by: prime-agent deepseek-v4-flash-0731 Assisted-by: prime-agent glm-5.3-flash Signed-off-by: Chaser Huang <huangkangjing@gmail.com>
Assisted-by: prime-agent glm-5.3-flash Signed-off-by: Chaser Huang <huangkangjing@gmail.com>
Assisted-by: prime-agent glm-5.3-flash Signed-off-by: Chaser Huang <huangkangjing@gmail.com>
…s helper Assisted-by: prime-agent glm-5.3-flash Signed-off-by: Chaser Huang <huangkangjing@gmail.com>
Assisted-by: prime-agent glm-5.3-flash Signed-off-by: Chaser Huang <huangkangjing@gmail.com>
Assisted-by: prime-agent glm-5.3-flash Signed-off-by: Chaser Huang <huangkangjing@gmail.com>
Most image edit models can already handle masked edit pretty well, especially if they're prompted accordingly. But this seems like a huge improvement for inpainting with regular diffusion model that don't have any native editing or inpainting capabilities. |
Yes, but the edit model still does not have true vision over the shape of the mask. In other words, the edit is still performed grossly over the entire image and then applied mask, and the prompt needs to describe how the edit is localized properly (e.g. if there are multiple dresses in the image and we only wants to change one, we need to state "change the color of the dress on the right", etc.) For some complex localized edits where such descriptions are tricky (e.g. editing part of a checkered pattern), Lanpaint can be a lot more helpful as well. |
|
Yes, but you can pass the mask as a reference, most edit models know how to interpret this. It adds more tokens to the context, which can slow it down, but probably not as much as using lanpaint. (I'm guessing lanpaint would be more low vram-friendly though) |
Summary
This PR adds lanpaint sampling implementation for sd.cpp, together with command line interface and documentation.
Lanpaint adds supports for training-free inpainting with any model by leveraging Langevin dynamics numerical methods. This algorithm particularly is ported from the Comfy implementation of lanpaint linked above.
Related Issue / Discussion
#1954
Additional Information
Example with comparisons:
Given input image (generated using Anima model with a separate prompt):
If we want to inpaint the dress of the character into a black dress using the following mask:
Without lanpaint, using the Anima model:
The model, without inpainting training, would struggle with the mask boundaries:

With lanpaint, a much better inpaint result would be obtained:
This method can also be paired with an image edit model to enable seamless pixel-identical masked edit
Checklist