leftthomas / ESPCN

A PyTorch implementation of ESPCN based on CVPR 2016 paper "Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Strange effect when test images

steven8274 opened this issue · comments

I build the python environment with anaconda, using python 3.7.13.When I run the image test cmd, there was an error reported.I search it with google, and find a solution with installing 'pillow 6.1.0'.Then I run the training cmd,there was an other error reported:
Traceback (most recent call last): File "train.py", line 116, in <module> engine.train(processor, train_loader, maxepoch=NUM_EPOCHS, optimizer=optimizer) File "/home/lxp/anaconda3/envs/hh_espcn/lib/python3.7/site-packages/torchnet/engine/engine.py", line 63, in train state['optimizer'].step(closure) File "/home/lxp/anaconda3/envs/hh_espcn/lib/python3.7/site-packages/torch/optim/adam.py", line 58, in step loss = closure() File "/home/lxp/anaconda3/envs/hh_espcn/lib/python3.7/site-packages/torchnet/engine/engine.py", line 56, in closure self.hook('on_forward', state) File "/home/lxp/anaconda3/envs/hh_espcn/lib/python3.7/site-packages/torchnet/engine/engine.py", line 31, in hook self.hooks[name](state) File "train.py", line 45, in on_forward meter_loss.add(state['loss'].data[0]) IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number
I search this again,and found an solution is change this code:
meter_loss.add(state['loss'].data[0])
to:
meter_loss.add(state['loss'].item())
After that the training process can be finished.I got the model file 'epoch_3_100.pt' in epoch directory.
However, when I use this model to test images, I got very strange effect like this:
BSD100_099
Did i do anything wrong in these steps?

@steven8274 You should use PyTorch 0.4, this code is 5 years ago.