zychen-ustc / PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors

Zeyuan Chen, Yangchao Wang, Yang Yang and Dong Liu. "PSD: Principled Synthetic-to-Real Dehazing Guided by Physical Priors". IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2021.
MIT License
115 stars 19 forks source link

test.py中使用“PSB-MSBDN”模型报错 #9

Closed LiMinghui19 closed 2 years ago

LiMinghui19 commented 2 years ago

test.py当我使用您提供的'PSD-FFANET'模型时测试没有问题; 但是当切换成使用‘’PSB-MSBDN‘’模型时报错:

RuntimeError: Error(s) in loading state_dict for DataParallel: Missing key(s) in state_dict: "module.convd4xconvd4x.conv2d.weight", "module.convd4xconvd4x.conv2d.bias". Unexpected key(s) in state_dict: "module.convd4x.conv2d.weight", "module.convd4x.conv2d.bias".

求解答!

zychen-ustc commented 2 years ago

您好!我这里test时似乎并没有遇到这个问题。报错信息中显示Missing key中有convd4xconvd4x,但是MSBDN里似乎应该没有这一项?

011043 commented 2 years ago

你好,我看您说使用您提供的'PSD-FFANET'模型时测试没有问题;想问一下您的测试方法?我在测试的时候遇到这个问题,多次修改之后还是未果,请问在测试过程中进行了哪些代码调整,以及测试图片是放在自己新建的data数据集中吗?

Traceback (most recent call last):
  File "D:\anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 3437, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-a7c6de5829d6>", line 1, in <module>
    runfile('C:/Users/sweet_li/Desktop/PSD/PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main/PSD/test.py', wdir='C:/Users/sweet_li/Desktop/PSD/PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main/PSD')
  File "D:\PyCharm 2021.2.3\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 198, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "D:\PyCharm 2021.2.3\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/Users/sweet_li/Desktop/PSD/PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main/PSD/test.py", line 35, in <module>
    test_data_loader = DataLoader(TestData_FFA(test_data_dir), batch_size=1, shuffle=False, num_workers=8) # For FFA and MSBDN
  File "C:\Users\sweet_li\Desktop\PSD\PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main\PSD\datasets\pretrain_datasets.py", line 489, in __init__
    self.haze_names = list(os.walk(self.haze_dir))[0][2]
IndexError: list index out of range
Shanfu2021 commented 2 years ago

你好,我看您说使用您提供的'PSD-FFANET'模型时测试没有问题;想问一下您的测试方法?我在测试的时候遇到这个问题,多次修改之后还是未果,请问在测试过程中进行了哪些代码调整,以及测试图片是放在自己新建的data数据集中吗?

Traceback (most recent call last):
  File "D:\anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 3437, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-a7c6de5829d6>", line 1, in <module>
    runfile('C:/Users/sweet_li/Desktop/PSD/PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main/PSD/test.py', wdir='C:/Users/sweet_li/Desktop/PSD/PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main/PSD')
  File "D:\PyCharm 2021.2.3\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 198, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "D:\PyCharm 2021.2.3\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/Users/sweet_li/Desktop/PSD/PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main/PSD/test.py", line 35, in <module>
    test_data_loader = DataLoader(TestData_FFA(test_data_dir), batch_size=1, shuffle=False, num_workers=8) # For FFA and MSBDN
  File "C:\Users\sweet_li\Desktop\PSD\PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main\PSD\datasets\pretrain_datasets.py", line 489, in __init__
    self.haze_names = list(os.walk(self.haze_dir))[0][2]
IndexError: list index out of range

I met the same problem.you can modify net.load_state_dict(torch.load('./PSD-MODELS/PSB-MSBDN')) to net.load_state_dict(torch.load('./PSD-MODELS/PSB-MSBDN'),False)