BasicSR icon indicating copy to clipboard operation
BasicSR copied to clipboard

Train ESRGAN size tensors problems

Open claragarciamoll opened this issue 3 years ago • 1 comments

Hi @xinntao, I'm trying to train ESRGAN with my own images. The GT images have a size of 256x256x3 and the LQ images have 128x128x3. I already crop both of datasets and I obtain images of 64x64x3 and 32x32x3.

Once I run the code, in the loss function (L1) I get a problem due to the tensors sizes. I attach the problem here: RuntimeError: The size of tensor a (16) must match the size of tensor b (8) at non-singleton dimension 3 . I also attach the tensors sizes: target tensor: torch.Size([8, 3, 16, 16]) and pred tensor: torch.Size([8, 3, 8, 8]).

Do you have any idea, why this is happening? Because as I can understood, the GT images should have higher resolution (in my case x2) with respect to the LQ images.

claragarciamoll avatar Jun 21 '21 11:06 claragarciamoll

Hello, solve this problem need you to change the structure of RRDB, found in basicsr rrdbnet_arch of the arch. then removing one upsample layer. So that matches the tensor dimension.Esrgan defaults to two upsampling layers

successhaha avatar Nov 26 '21 15:11 successhaha