DPIR icon indicating copy to clipboard operation
DPIR copied to clipboard

main_dipr_sisr throws input type RuntimeError

Open rishftw opened this issue 4 years ago • 0 comments

Hi, I was trying to run the main_dipr_sisr.py(inconsistent naming, the rest say dpir) in colab like this:

!python main_dipr_sisr.py

it gives me this output:

`LogHandlers setup!

20-09-28 07:21:02.662 : model_name:drunet_color, image sigma:0.000, model sigma:0.000 20-09-28 07:21:02.664 : Model path: model_zoo/drunet_color.pth 20-09-28 07:21:02.664 : testsets/srbsd68 20-09-28 07:21:02.669 : --------- sf:2 --k: 0 --------- Traceback (most recent call last): File "main_dipr_sisr.py", line 301, in main() File "main_dipr_sisr.py", line 222, in main x = utils_model.test_mode(model, x, mode=3, refield=32, min_size=256, modulo=16) File "/content/drive/My Drive/dpir/DPIR/utils/utils_model.py", line 36, in test_mode E = test_x8(model, L, modulo) File "/content/drive/My Drive/dpir/DPIR/utils/utils_model.py", line 164, in test_x8 E_list = [test_pad(model, util.augment_img_tensor(L, mode=i), modulo=modulo) for i in range(8)] File "/content/drive/My Drive/dpir/DPIR/utils/utils_model.py", line 164, in E_list = [test_pad(model, util.augment_img_tensor(L, mode=i), modulo=modulo) for i in range(8)] File "/content/drive/My Drive/dpir/DPIR/utils/utils_model.py", line 68, in test_pad E = model(L) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 722, in _call_impl result = self.forward(*input, **kwargs) File "/content/drive/My Drive/dpir/DPIR/models/network_unet.py", line 106, in forward x1 = self.m_head(x0) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 722, in _call_impl result = self.forward(*input, **kwargs) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/conv.py", line 419, in forward return self._conv_forward(input, self.weight) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/conv.py", line 416, in _conv_forward self.padding, self.dilation, self.groups) RuntimeError: Input type (torch.cuda.DoubleTensor) and weight type (torch.cuda.FloatTensor) should be the same `

I got it to run by adding this

L = L.float()

to the function

test_mode(model, L, mode=0, refield=32, min_size=256, sf=1, modulo=1)

in DPIR/utils/utils_model.py right before the if statements, however I do not know enough to tell if using a simple cast like that causes any internal problems. Thought I'd put this here in case anyone else runs into the issue.

rishftw avatar Sep 28 '20 07:09 rishftw