-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Image2Image fit option blends pixels when scaling down which ruins mask edges #625
Comments
I see the problem. Would the PIL.Image.Resampling.NEAREST resampling filter be the best choice here? |
@lstein Seems like that would do it. There's definitely a quality difference when using nearest neighbor vs the other methods, though, so it'd probably be best as a parameter. Either that or I suppose you could switch to nearest neighbor when transparent pixels/inpainting is detected. |
I'll give it a try as soon as I get access to my development environment again. (It's an HPC cluster down for maintenance over the weekend). In the meantime, if you'd like to swap the nearest resampling in, just open the file ldm/dream/image_util.py, look for the line |
- change image resampling method for mask shrinkage to prevent artifacts at edge of mask Addresses #625
This should be fixed now. |
- change image resampling method for mask shrinkage to prevent artifacts at edge of mask Addresses invoke-ai#625
Describe your environment
Describe the bug
When passing a masked image with "fit" enabled, it scales down the image and blends the pixels in the process. This causes artifacts near the edges in the output. Maybe there should be a "nearest neighbor" scaling option?
To Reproduce
Images:
Source image:
Large masked image (2496x1664):
Small masked image (960x640):
Steps to reproduce the behavior:
Expected behavior
There should be no seams/artifacts in the masked area. The resulting image should be seamless
Screenshots
Large image output:
Small image output:
Additional context
Could you add a nearest neighbor/non-filtered scaling option so the pixels don't get blurred? I like the "fit" option because I don't have to resize images on my own, so it would be nice if it handled masked images well.
The text was updated successfully, but these errors were encountered: