sanghyun-son / EDSR-PyTorch

PyTorch version of the paper 'Enhanced Deep Residual Networks for Single Image Super-Resolution' (CVPRW 2017)
MIT License
2.44k stars 673 forks source link

Why the **psnr** is zero or nan? #332

Open rezraz1 opened 2 years ago

rezraz1 commented 2 years ago

Hi, I tried to run python main.py --data_test Demo --scale 4 --pre_train download --test_only --save_results I had a few errors that I was able to fix with the help of [https://github.com/sanghyun-son/EDSR-PyTorch/issues/105] and [https://github.com/sanghyun-son/EDSR-PyTorch/issues/91] but now I have this problem. What could be the reason for this?

These are the works I have done so far to fix the errors :

error 1: AttributeError: Can't pickle local object 'checkpoint.begin_background..bg_target' and E0FError: Ran out of input Resolved with : https://github.com/sanghyun-son/EDSR-PyTorch/issues/105#issuecomment-455825866 : It seems there are some conflicts between multiprocessing and your system. Remove this and these lines to disable multiprocessing.

error 2 : AttributeError: 'checkpoint' object has no attribute 'queue' Resolved with : removing --save_results

error 3 : [WinError 1455] The paging file is too small for this operation to complete. Resolved with : It is clear that --n_threads 0 is used to fix this error

also my system settings :

windows 8.1 python 3.8.5 base conda pytorch 1.8.2+cuda10.2

The result i get now is this :

 Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

E:\EDSR-PyTorch-master\EDSR-PyTorch-master\src>python ma
in.py --data_test Demo --scale 4 --pre_train download --test_only --n_threads 0
Making model...
Download the model

Evaluation:
  0%|                                                     | 0/1 [00:00<?, ?it/s]
100%|█████████████████████████████████████████████| 1/1 [00:02<00:00,  2.01s/it]
100%|█████████████████████████████████████████████| 1/1 [00:02<00:00,  2.01s/it]

[Demo x4]       PSNR: 0.000 (Best: 0.000 @epoch 1)
Forward: 2.01s

Saving...
Total: 2.01s

Question :

Why the psnr is always zero even if I put a few images in the file or it would be nan if i use benchmark data? What is the problem and what should I do to fix it?

Thank you for your help . . . @tabetomo @5496gaoziya @mylifeasazucchini I will be very thankful if help me, Best Regards

mylifeasazucchini commented 2 years ago

I haven't worked with this repo for a long time but have you tried it this way: (I downloaded the models and that's why I specified the path)

python main.py --data_test Demo --scale 4 --pre_train ../models/EDSR_x4.pt --n_resblocks 32 --n_feats 256 --res_scale 0.1 --test_only --save_results

Also what are the kinds of results that are saved as of now ? Some people reported seeing only artifacts ? But if it's just about PSNR have you passed the GT images as well ? or maybe just measure it after they are saved ?

rezraz1 commented 2 years ago

Thank you very much for your help. I realized that it is better for me to use ready-made and trained models, but I encountered the problem of GPU and CUDA. Do you know how I can solve this problem? ................................................................................................................................................................................................................................. https://github.com/sanghyun-son/EDSR-PyTorch/issues/333#issue-1270469528 ................................................................................................................................................................................................................................. I tried to run the code with trained models (EDSR) and got an error about CUDA and GPU that is given below :

RuntimeError: CUDA out of memory. Tried to allocate 2.64 GiB (GPU 0; 4.00 GiB to
tal capacity; 1.15 GiB already allocated; 2.21 GiB free; 1.19 GiB reserved in to
tal by PyTorch)

Apparently this error occurs due to the GPU, now I want to know if there is a possibility for the code to run on the CPU? How can the code be changed? (If we consider that there is no memory problem.)

@mylifeasazucchini

mylifeasazucchini commented 2 years ago

I am afraid 4 GB is way too small GPU for running this model, but maybe try running the code in cpu mode ? There are quite many ways:

  1. one way could be that in main.py you could write:

os.environ['CUDA_VISIBLE_DEVICES'] = '-1'

  1. or find out the place where they define "device" and explicitly set it to use "cpu" by this line:

device = torch.device("cpu")

  1. and if you are on a linux system, even better! I think you could just re-write the calls as such:

CUDA_VISIBLE_DEVICES=-1 python main.py ......... (pass arguments)

Good luck!!

Liiiiaictx commented 10 months ago

@rezraz1 你好,我测试基准数据集出现AttributeError: module 'torch.backends' has no attribute 'mps',请问怎么解决?

lleybey commented 7 months ago

@rezraz1你好,我测试基准数据集出现AttributeError: module 'torch.backends' has no attribute 'mps',请问怎么解决?

可能是你torch版本太高,在你的版本中已经删除了mps这个参数,可以试试将关于mps的代码改为 if self.cpu: self.device = torch.device('cpu') else: if torch.cuda.is_available(): self.device = torch.device('cuda') else: self.device = torch.device('cpu')