examples icon indicating copy to clipboard operation
examples copied to clipboard

Input type and weight type should be the same

Open mahmoodn opened this issue 5 years ago • 2 comments

For the super resolve run, I get this error

$ python super_resolve.py --input_image dataset/BSDS300/images/test/16077.jpg --model model_epoch_30.pth --output_filename out.png
Namespace(cuda=False, input_image='dataset/BSDS300/images/test/16077.jpg', model='model_epoch_30.pth', output_filename='out.png')
Traceback (most recent call last):
  File "super_resolve.py", line 29, in <module>
    out = model(input)
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/mahmood/cactus/pt/pytorch/examples/super_resolution/model.py", line 20, in forward
    x = self.relu(self.conv1(x))
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/conv.py", line 339, in forward
    self.padding, self.dilation, self.groups)
RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same

Any idea?

P.S: Although readme file says model_epoch_500.pth, but with --nEpochs 30, I see model_epoch_30.pth

mahmoodn avatar Aug 01 '19 13:08 mahmoodn

not an expert but you can resolve it using --cuda arg inthe inference command

romanoss avatar Sep 21 '19 18:09 romanoss

@romanoss is correct although it may be worth making a simple change to make this example work on cpu as well

msaroufim avatar Mar 10 '22 00:03 msaroufim