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

Issue with hiresfix #1

Closed
sALTaccount opened this issue Mar 7, 2023 · 6 comments
Closed

Issue with hiresfix #1

sALTaccount opened this issue Mar 7, 2023 · 6 comments

Comments

@sALTaccount
Copy link
Owner

img2img and hiresfix use the encoder block of the VAE. Possible apply the inverse operation to the first layer of the encoder? Will need to do testing

@catboxanon
Copy link

Was just about to open this issue, the VAE provided here in this repo and the on-the-fly modification via this extension have the same problem.

@sALTaccount
Copy link
Owner Author

Fixed the problem, will update this repo and make a PR on the extension soon
Left is with the fix and right is without
No hiresfix
image
R-ESRGAN 4x+ Anime6B hires upscaler
image
Notice how the old (right) loses contrast again from passing through the VAE. However, by implying the inverse operation to the VAEs encoder, we can preserve the contrast.

@sALTaccount
Copy link
Owner Author

sALTaccount commented Mar 7, 2023

However, this method isn't perfect. We are actually modifying the latents themselves this way. This can cause the images to not look as good. However, the effect shouldn't be noticable because we are going to add a ton of noise to the latents anyways. Note that this will not affect anything besides hiresfix and img2img.
image
Just passing the image into the VAE and back out destroys a bit of quality. However, I don't see any use just passing images through a VAE, generally they are being used with denoising as well, so the quality difference shouldn't make a noticeable impact.

@sALTaccount
Copy link
Owner Author

901498c

@catboxanon
Copy link

catboxanon commented Mar 8, 2023

Isn't brightness now applying the same operation as contrast? bias is only mentioned in the comment and not actually used in the code now. Actually it looks like the brightness code is copied from contrast verbatim, including variables.

@sALTaccount
Copy link
Owner Author

yeah.......... just fixed that 😓

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

No branches or pull requests

2 participants