knazeri / edge-informed-sisr

Edge-Informed Single Image Super-Resolution, ICCVW 2019 https://arxiv.org/abs/1909.05305
Other
78 stars 20 forks source link

hr_image and hr_edge are in different sizes #4

Open n0acar opened 5 years ago

n0acar commented 5 years ago

The shape of hr_image is 3,256,256 however hr_edge is 1,70,70. I couldn't find anything relatable with 70. I made the change with cuda as in issue #1 . What might be the problem here? Where does 70 come. I use edge enhancer and sr model together in mode 3 and super resolution scale is 8.

Traceback (most recent call last): File "main.py", line 120, in main() File "main.py", line 50, in main model.train() File "/scratch/users/nacar14/edge-informed-sisr/src/edge_match.py", line 120, in train hr_images_pred, gen_loss, dis_loss, logs = self.sr_model.process(lr_images, hr_images, lr_edges, hr_edges_pred) File "/scratch/users/nacar14/edge-informed-sisr/src/models.py", line 214, in process outputs = self(lr_images, hr_edges) File "/kuacc/users/nacar14/miniconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in call result = self.forward(*input, **kwargs) File "/scratch/users/nacar14/edge-informed-sisr/src/models.py", line 269, in forward inputs = torch.cat((hr_images, hr_edges), dim=1) RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 256 and 70 in dimension 2 at /opt/conda/conda-bld/pytorch_1573049306803/work/aten/src/THC/g\ eneric/THCTensorMath.cu:71

pppyykknen commented 4 years ago

This is caused by hard coded stride value in models.py line 262. Replace

hr_images = F.conv_transpose2d(lr_images, self.scale_kernel, padding=0, stride=2, groups=3) with hr_images = F.conv_transpose2d(lr_images, self.scale_kernel, padding=0, stride=self.config.SCALE, groups=3)

to fix the problem.