hongyuanyu / SPAN

Swift Parameter-free Attention Network for Efficient Super-Resolution
Apache License 2.0
135 stars 6 forks source link

img_range parameter incorrect for BasicSR implementation #6

Open terrainer opened 9 months ago

terrainer commented 9 months ago

Hi,

Thank you for your code! This performs very impressively at such fast speeds and low memory usage. This BasicSR implementation has one major flaw in its img_range parameter. The default value is 255., but a much more suitable value would be 1..

This is because BasicSR normalizes inputs to a range of [0,1]. EDSR, which is seemingly where the 255. value comes from, does not do this, and also does its zero-centering via a much different MeanShift function. You'll notice that any other network with a BasicSR implementation and this same mean/range code, such as SwinIR , uses the value of 1..

Currently, the usage of this value vastly blows up expected ranges of [0,1] or [-0.5, 0.5] to [-127.5, 127.5], causing high instability. Unfortunately, the editing of this parameter also breaks inference for anything expecting img_range to be 255., and so the current official pretrains would not work if inference were to be done with img_range: 1.. They would have to be re-trained with the updated value.

Kind regards, terrainer

reddured commented 4 months ago

Could this issue be related to the problem you mentioned ? https://github.com/hongyuanyu/SPAN/issues/9

terrainer commented 4 months ago

Could this issue be related to the problem you mentioned ? #9

Very likely to be the case

reddured commented 4 months ago

I noticed you finetuned some SPAN models yourself (like SPANkendata). Have you managed to correct this issue or at least mitigate pixel artifacts on output image ? It doesn't seem to appear on the comparison shot related to your SPANkendata model (https://github.com/terrainer/AI-Upscaling-Models/blob/main/4xSPANkendata/comparison/Upscale.png). Thanks.

terrainer commented 3 months ago

The issue is fixed within chaiNNer and neosr.

On Wed, 24 July 2024, 8:00 pm reddured, @.***> wrote:

I noticed you finetuned some SPAN models yourself (like SPANkendata). Have you managed to correct this issue or at least mitigate pixel artifacts on output image ? It doesn't seem to appear on the comparison shot related to your SPANkendata model ( https://github.com/terrainer/AI-Upscaling-Models/blob/main/4xSPANkendata/comparison/Upscale.png). Thanks.

— Reply to this email directly, view it on GitHub https://github.com/hongyuanyu/SPAN/issues/6#issuecomment-2247452000, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHQ7OIQ2CXJXUOOZH77YCEDZN53L3AVCNFSM6AAAAABLL2ZFM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENBXGQ2TEMBQGA . You are receiving this because you authored the thread.Message ID: @.***>

reddured commented 3 months ago

Do you mean this is fixed in chaiNNer / neosr by using a denoising algorithm on output image (like NLM denoising) ?

terrainer commented 3 months ago

ChaiNNer and neosr have changed the code itself to fix the img_range issue.

This also makes models trained using this repos code incompatible with those two.

On Fri, 2 Aug 2024, 1:09 am reddured, @.***> wrote:

Do you mean this is fixed in chaiNNer / neosr by using a denoising algorithm on output image (like NLM denoising) ?

— Reply to this email directly, view it on GitHub https://github.com/hongyuanyu/SPAN/issues/6#issuecomment-2263314557, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHQ7OITNEDS2TZW2WFFOIO3ZPJFRVAVCNFSM6AAAAABLL2ZFM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRTGMYTINJVG4 . You are receiving this because you authored the thread.Message ID: @.***>