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

Improved parameter detection for Compact #29

Merged
merged 4 commits into from
Nov 21, 2023
Merged

Conversation

RunDevelopment
Copy link
Member

Changes:

  • Removed the pixelshuffle_shape parameter. We are now using the exact model code from the Real-ESRGAN repo.
  • Improved detection of output channels and scale. We now support grayscale to RGB compact models.
  • Added tests to verify the new detection code.

The new detection code is actually pretty simple: we just brute force it. We know that the number x we read from the state dict is x = scale * scale * out_nc. We also know that out_nc is either 1, 3, or 4. So we just have to try out all possible values for out_nc see which one fulfills the formula for x.

Unfortunately, this method does not work correctly when the actual number of output channels is 1 or 4, because 1 and 4 are square numbers. E.g. for scale=3 and out__nc=4 we get x=36, but scale=6 and out_nc=1 also produces x=36. To fix this, we make the assumption that out_nc=in_nc is likely. E.g. if in_nc=4, we will prefer out_nc=4 over out_nc=1.

Copy link
Member

@joeyballentine joeyballentine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work

@joeyballentine joeyballentine merged commit 79acd35 into main Nov 21, 2023
7 checks passed
@joeyballentine joeyballentine deleted the impr-compact-detect branch November 21, 2023 14:21
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