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时出现问题 #10

Closed 011043 closed 2 years ago

011043 commented 2 years ago

您好,我在尝试运行test.py文件时遇到下列问题。 我将需要测试的图片放在新建的data文件夹中,但是出现以下问题

C:\Users\sweet_li\Desktop\PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main\PSD\datasets\pretrain_datasets.py:62: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if list(haze.shape)[0] is not 3 or list(gt.shape)[0] is not 3:
C:\Users\sweet_li\Desktop\PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main\PSD\datasets\pretrain_datasets.py:62: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if list(haze.shape)[0] is not 3 or list(gt.shape)[0] is not 3:
C:\Users\sweet_li\Desktop\PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main\PSD\datasets\pretrain_datasets.py:124: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if list(haze.shape)[0] is not 3 or list(gt.shape)[0] is not 3:
C:\Users\sweet_li\Desktop\PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main\PSD\datasets\pretrain_datasets.py:124: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if list(haze.shape)[0] is not 3 or list(gt.shape)[0] is not 3:
Traceback (most recent call last):
  File "C:/Users/sweet_li/Desktop/PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main/PSD/test.py", line 38, 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-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main\PSD\datasets\pretrain_datasets.py", line 491, in __init__
    self.haze_names = list(os.walk(self.haze_dir))[0][2]
IndexError: list index out of range

进程已结束,退出代码为 1

在我注释掉self.haze_names = list(os.walk(self.haze_dir))[0][2]这一行之后,又出现

D:\anaconda\python.exe C:/Users/sweet_li/Desktop/PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main/PSD/test.py
C:\Users\sweet_li\Desktop\PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main\PSD\datasets\pretrain_datasets.py:62: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if list(haze.shape)[0] is not 3 or list(gt.shape)[0] is not 3:
C:\Users\sweet_li\Desktop\PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main\PSD\datasets\pretrain_datasets.py:62: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if list(haze.shape)[0] is not 3 or list(gt.shape)[0] is not 3:
C:\Users\sweet_li\Desktop\PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main\PSD\datasets\pretrain_datasets.py:124: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if list(haze.shape)[0] is not 3 or list(gt.shape)[0] is not 3:
C:\Users\sweet_li\Desktop\PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main\PSD\datasets\pretrain_datasets.py:124: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if list(haze.shape)[0] is not 3 or list(gt.shape)[0] is not 3:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\anaconda\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "D:\anaconda\lib\multiprocessing\spawn.py", line 125, in _main
    prepare(preparation_data)
  File "D:\anaconda\lib\multiprocessing\spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "D:\anaconda\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "D:\anaconda\lib\runpy.py", line 265, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "D:\anaconda\lib\runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "D:\anaconda\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\sweet_li\Desktop\PSD-Principled-Synthetic-to-Real-Dehazing-Guided-by-Physical-Priors-main\PSD\test.py", line 47, in <module>
    for batch_id, val_data in enumerate(test_data_loader):
  File "D:\anaconda\lib\site-packages\torch\utils\data\dataloader.py", line 359, in __iter__
    return self._get_iterator()
  File "D:\anaconda\lib\site-packages\torch\utils\data\dataloader.py", line 305, in _get_iterator
    return _MultiProcessingDataLoaderIter(self)
  File "D:\anaconda\lib\site-packages\torch\utils\data\dataloader.py", line 918, in __init__
    w.start()
  File "D:\anaconda\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "D:\anaconda\lib\multiprocessing\context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "D:\anaconda\lib\multiprocessing\context.py", line 327, in _Popen
    return Popen(process_obj)
  File "D:\anaconda\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "D:\anaconda\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
    _check_not_importing_main()
  File "D:\anaconda\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main
    raise RuntimeError('''
RuntimeError: 
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

基于我现在的代码水平,确实没有找到解决办法,请问能给予解决答复吗?

zychen-ustc commented 2 years ago

您好。这里的self.haze_names是用于获取文件夹下所有文件名的变量。因为我不知道你的data文件夹下的文件排布是怎么样的,无法给出具体的建议。但如果os.walk会报错的话,也可以尝试os.listdir这个函数或者其它一些遍历文件夹获取文件名的函数。对于第二个问题,我也无法直接根据log看出具体的问题。可以尝试把 is not 3 替换成 !=3 试试看?

Kamehameha111 commented 2 years ago

我也是先 IndexError: list index out of range 再 RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.
Kamehameha111 commented 2 years ago

您好。这里的self.haze_names是用于获取文件夹下所有文件名的变量。因为我不知道你的data文件夹下的文件排布是怎么样的,无法给出具体的建议。但如果os.walk会报错的话,也可以尝试os.listdir这个函数或者其它一些遍历文件夹获取文件名的函数。对于第二个问题,我也无法直接根据log看出具体的问题。可以尝试把 is not 3 替换成 !=3 试试看?

您好。这里的self.haze_names是用于获取文件夹下所有文件名的变量。因为我不知道你的data文件夹下的文件排布是怎么样的,无法给出具体的建议。但如果os.walk会报错的话,也可以尝试os.listdir这个函数或者其它一些遍历文件夹获取文件名的函数。对于第二个问题,我也无法直接根据log看出具体的问题。可以尝试把 is not 3 替换成 !=3 试试看?

您好,请问“获取文件夹下所有文件名”是指哪个文件夹?谢谢!

zychen-ustc commented 2 years ago

是指数据集所在的文件夹。您的报错信息看起来似乎是多进程相关部分有问题