SeungjunNah/DeepDeblur-PyTorch

RuntimeError: Sizes of tensors must match except in dimension 3. Got 348 and 347

Closed this issue · 3 comments

Helo @SeungjunNah , Thanks for your great works on this great repository.

But I have some problem here, I have tried to run demo from your repo (I have python 3.8.3), Using the following steps:

  1. I clone your repositories, create conda environtment install pytorch 1.5.0 using conda install -c pytorch pytorch
  2. Install all the requirements, download pretrained model
  3. Run using the following command line python main.py --demo true --save_dir GOPRO_L1_amp --demo_input_dir INPUT_DIR --demo_output_dir OUTPUT_DIR

then occurs this errors:
following Error

after I forcing the dimension using some modification line in MSResNet.py like this:

input_s = input_pyramid[-1]
for s in scales:    # [2, 1, 0]
      output_pyramid[s] = self.body_models[s](input_s)
      if s > 0:
         up_feat = self.conv_end_models[s](output_pyramid[s])
         bound3 = input_pyramid[s-1].size()[3]
         bound2 = input_pyramid[s-1].size()[2]
         input_s = torch.cat((input_pyramid[s-1], up_feat[:, :, :bound2, :bound3]), 1)

I can run the demo scripts, but got the different result with yours as the following:
sample22

The first image (top position) is my result, and the second image (bottom position) is yours. Mine is a little bit blurred than yours, can you figure out why? and can you handdle my errors? thank you for your reply

Hi @ziyadn,

I tried to reproduce the error, but couldn't.
python main.py --save_dir GOPRO_L1_amp --demo true --demo_input_dir Research/dataset/GOPRO_Large/test/GOPR0384_11_00/blur_gamma --demo_output_dir temp
The error message says that the image resolution in the multi-scale architecture did not match to the corresponding feature. But the size looks a little bit strange.
The GOPRO_Large dataset resolution is 1280*720. As the downsampling ratio is 2 per level, the 3rd dimension size should be 720 or 360 at the concatenation operation.
Did you resize or crop the images before running the demo?
I guess your image height would be 695. (695 // 2 = 347)
In that case, the results could be different.

As there is no padding operation at the demo, image sizes that are not divisible by 4 could cause such errors. I will fix it.

Now the code is updated so that inputs are padded when they are not divisible by 2**(n_scales-1).
I expect your example would not show the error message.

Closed due to inactivity.