dearleiii / PDSR

Submission to the PIRM2018 Super Resolution Contest
Other
2 stars 0 forks source link

RuntimeError: Can't call numpy() on Variable that requires grad. Use var.detach().numpy() instead.` #1

Closed dearleiii closed 6 years ago

dearleiii commented 6 years ago

[Epoch 1] Learning rate: 2.50e-6 down loss: process bicubically original size is: torch.Size([8, 3, 192, 192]) type: <class 'torch.Tensor'> Traceback (most recent call last): File "main.py", line 19, in t.train() File "/usr/project/xtmp/superresoluter/code/main/code_lei2/trainer.py", line 52, in train loss = self.loss(sr, hr) File "/home/home2/leichen/.local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 491, in call result = self.forward(*input, kwargs) File "/usr/project/xtmp/superresoluter/code/main/code_lei2/loss/init.py", line 97, in forward sr_down = bicubic_down(sr) File "/usr/project/xtmp/superresoluter/code/main/code_lei2/loss/downsr.py", line 21, in bicubic_down misc.imsave(str(idx)+"_ori.png", each_batch) File "/home/home2/leichen/.local/lib/python3.5/site-packages/numpy/lib/utils.py", line 101, in newfunc return func(*args, *kwds) File "/home/home2/leichen/.local/lib/python3.5/site-packages/scipy/misc/pilutil.py", line 217, in imsave im = toimage(arr, channel_axis=2) File "/home/home2/leichen/.local/lib/python3.5/site-packages/numpy/lib/utils.py", line 101, in newfunc return func(args, kwds) File "/home/home2/leichen/.local/lib/python3.5/site-packages/scipy/misc/pilutil.py", line 320, in toimage data = asarray(arr) File "/home/home2/leichen/.local/lib/python3.5/site-packages/numpy/core/numeric.py", line 492, in asarray return array(a, dtype, copy=False, order=order) File "/home/home2/leichen/.local/lib/python3.5/site-packages/torch/tensor.py", line 376, in array return self.cpu().numpy() RuntimeError: Can't call numpy() on Variable that requires grad. Use var.detach().numpy() instead.

dearleiii commented 6 years ago

misc.imsave can only save from the PIL type, not tensor object.