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

How to limit the range of the super-resolved image #132

Open
antonelse opened this issue Mar 6, 2024 · 2 comments
Open

How to limit the range of the super-resolved image #132

antonelse opened this issue Mar 6, 2024 · 2 comments

Comments

@antonelse
Copy link

Hi, just a curiosity.

What are the main parameters that influence the final output range if I do not consider the final scaling and rescaling thus the plain x here, without x = (x - self.mean) * self.img_range and x = x / self.img_range + self.mean.

Because I'm trying to use it with an image bounded between 0 and 1, but it gives output values from -30 to +200, and I don't know why. I'm doing this because I want to apply this algorithm to non-real images, like temperature or gas emissions maps.

If i force the net to output values bounded between 0 and 1, i.e. x[x<0]=0 and x[x>1]=1 I obtain images filled with ones, thus the training stops after some epochs since the loss is nearly constant and does not improve.

Thanks a lot!

@antonelse antonelse changed the title Ho to limit the range of the super-resolved image How to limit the range of the super-resolved image Mar 6, 2024
@chxy95
Copy link
Member

chxy95 commented Mar 8, 2024

@antonelse The model process data in float32 and the image is processed into [0,1] range in the data loader. If you want to save the float data instead of the uint8 data ranging [0,255], modify the model file avoiding tensor2img. https://github.com/XPixelGroup/BasicSR/blob/033cd6896d898fdd3dcda32e3102a792efa1b8f4/basicsr/models/sr_model.py#L208

@antonelse
Copy link
Author

antonelse commented Mar 8, 2024

Thanks @chxy95 !
The problem is that, after some batches, the network tries to shrink the values to match the input range of the image, but after some epochs, it explodes, returning values far above the original range.
To avoid this, I wanted to know how I could act to reduce the problem in the image synthesis part and prevent this unusual behavior.

In short: the net's output is not bounded between 0 and 1. Is it normal ? If so, how to handle this?

I'll experiment with some regularization and gradient clipping techniques.
If you have any suggestions, I'm here :)
Many thanks.

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