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 crop output padding for pixel unshuffle esrgan #310

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

the-database
Copy link
Contributor

@the-database the-database commented Oct 18, 2024

For ESRGAN with pixel unshuffle mode, the input is padded and then the output is cropped to ensure the output resolution is correct, but the cropping has a small bug. When using pixel unshuffle self.scale is always 4 and the true scale can be recovered with self.shuffle_factor (as is done here).

The existing code does the crop assuming self.scale is the true scale, so when the true scale is 1 or 2, the indexes are larger than they should be and no cropping is actually done. This causes the output image to be slightly larger than it should be.

In practice this doesn't affect much, downstream software like chaiNNer is unaffected since it uses ImageModelDescriptor which performs its own crop. But it seems like a good idea to fix anyway?

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.

1 participant