yulunzhang / RCAN

PyTorch code for our ECCV 2018 paper "Image Super-Resolution Using Very Deep Residual Channel Attention Networks"
1.37k stars 313 forks source link

why code for dataloader is this complicated??? #102

Open BarCodeReader opened 4 years ago

BarCodeReader commented 4 years ago

first thanks for your code.

but TBH, why the code for dataloader is so complex and so hard to read???

FizzerYu commented 3 years ago

Just personal opinion.

Some of the prepossessing code of RCAN is inherit from EDSR . And MDSR(a model proposed with EDSR in the same paper) support multi-scale training.

At each update of training a multi-scale model (MDSR), we construct the minibatch with a randomly selected scale among ×2, ×3 and ×4. (Ref: https://arxiv.org/pdf/1707.02921.pdf)

So when MDSR is training, the data_generator function should randomly select a scale to train the model. This feature need a custom dataloader function(See dataloader.py line 37-45).

By the way, Thanks for the code of RCAN. :)

BarCodeReader commented 3 years ago

So when MDSR is training, the data_generator function should randomly select a scale to train the model. This feature need a custom dataloader function(See dataloader.py line 37-45).

but why we cannot prepare the DIV2K in scale 2,3,4 then randomly crop a patch and feed into loader? DRRN is using this approach, though it trains on 291 dataset, it is also multi-scale training.

now the dataloader is so long and hard to read/understand what is going on.

FizzerYu commented 3 years ago

Sorry, I'm just a fresh man in Super-resolution. And I haven't read the source code of the DRRN. Maybe it's just author's perference.

I have also face the same problem in dataloader. And it's incompatible with Torch1.6. But if you have some patience and read the dataloader source code of the PyTorch 0.4.1(The author proposed). Most of the code in dataloader.py is the same.

Besides, the RCAN doesn't use multi-scale training, so you could just replace MSDataLoader with torch.utils.data.dataloader. Also you need to change some Args passed to this Function.(I'm testing this method and it seems that the data could be read properly)