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

Worse quality on every "iteration" of inpainting #100

Open
user425846 opened this issue Jun 26, 2023 · 8 comments
Open

Worse quality on every "iteration" of inpainting #100

user425846 opened this issue Jun 26, 2023 · 8 comments
Labels
error Something isn't working

Comments

@user425846
Copy link

user425846 commented Jun 26, 2023

Hi,

whenever i send an inpainted image back to inpainting and do another inpainting prompt, the quality of the image gets progessively worse. I have seen people inpainting for hours with stable diffusion with hundreds or thousand iterations and no loss in quality. Is there anything i can do about that? Why is it so different between SD and Kandinsky?

@user425846
Copy link
Author

user425846 commented Jun 26, 2023

I have attached 3 images here doing some random inpainting, 1. the starting image, 2. after some inpainting, 3. after more inpainting. You can see the quality getting progressively worse. It is obviously caused by saving and putting in the PNG over and over again, but im wondering how we can do inpainting without quality loss.

initial

few-inpaintings

more-inpaintings

@seruva19
Copy link
Owner

Yes, I noticed the same (#23). Clearly there is something wrong about the conversion of the input image. Maybe I will need to rewrite the whole inpainting method :(

@seruva19 seruva19 added the error Something isn't working label Jun 26, 2023
@user425846
Copy link
Author

Okay interesting, sorry for not seeing the previous issue.

Here is an example using diffusers: https://huggingface.co/kandinsky-community/kandinsky-2-1-inpaint and even in their sample image you can already see a degradation in quality / colors from just one inpainting

@seruva19
Copy link
Owner

Yes, that's weird.
There is implementation of inpainting in Kandinsky extension for Automatic (https://github.com/MMqd/kandinsky-for-automatic1111/blob/main/scripts/kandinsky.py) - I have to check if it works properly and if it does, I will adapt their code.

@user425846
Copy link
Author

I will give it a shot, will get back to you when i tested it

@user425846
Copy link
Author

Okay, so, in this extension, there is a setting called "inpaint area", with 2 options: "Whole picture" and "only masked". These are different options from the masking. The masking still applies, even when choosing whole picture.

When i choose whole picture, i get the same result as with your script, degrading quality. But when i choose only masked, there is no degradation in quality in the rest of the image. However, the edge of the mask is very, very clearly visible and the result of the inpainting is not very good, it doesnt fit as well in the picture as the whole picture mode.

@user425846
Copy link
Author

Some examples: 1.png: Initial image, 2.png: Using whole picture mode, it fits very well, but the quality of the rest of the image degrades, 3.png: It fits horribly and the borders of the masking are clearly visible, but not degredation in quality for the rest of the image

1
2
3

@seruva19
Copy link
Owner

Thank you for your analysis, it's really helpful 👍 I will try to fix it ASAP.

seruva19 added a commit that referenced this issue Jun 19, 2024
- With 'inpainting composition=mask' pixel data defined by the mask shape is pasted over original image, instead of using whole inpainted image
- It was aimed to partially solve #100, but the borders of the mask are still clearly visible on the resulting image, so the issue was not solved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants