Skip to content
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 inpaint only masked pixels are shifted #16243

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

light-and-ray
Copy link
Contributor

@light-and-ray light-and-ray commented Jul 20, 2024

Description

Fixes bug: pasted image is shifted right and down on factor number of pixels after it was upscaled by this factor

This bug wasn't seen very often because rounded scale factor was almost always 1, and mask blur by default hides this artifact

Also this PR adds option to correct padding to have integer upscale on applying overlay

Screenshots/videos:

Original:
original

Options: padding=28, mask_blur=0, resolution=451x451, bad quality because I've used LCM, do not care about it

Old behavior:
old

Integer option on, but bug exists:
integer_and_NO_fix
Here scale factor become 2, and it started look like a disaster. And this can happen and happens in current behavior anciently, if scale factor > 1 and upscale non integer

Integer option on and fixed bug:
integer_and_fix

Because this integer upscale correction can increase padding on 50-150 pixels, I've made it optional. If option is off, result is still better then the old behavior, but upscale is not integer (worse fit, better resolution):

Integer option off and fixed bug:
fix

Checklist:

modules/processing.py Show resolved Hide resolved
@light-and-ray
Copy link
Contributor Author

light-and-ray commented Oct 28, 2024

I have added a threshold. Because I can't find any other idea why it happens in 256p, except maybe due to lower resolution is 1st case - more details are gone. I find it logical

Also I saw this problem that @w-e-w you found in action, after I added aspect ratio correction in my extension which I mentioned above. It sometimes became less then 300-400 pч
+ I have deleted integer_only_masked option in the new commit, because it's not really useful, and buggy.

@light-and-ray light-and-ray changed the title Fix inpaint only masked + Integer upscale in inpaint only masked Fix inpaint only masked pixels are shifted Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants