python TypeError:无法pickle cv2.CLAHE对象

erhoui1w  于 2023-11-15  发布在  Python
关注(0)|答案(2)|浏览(136)

我正在GitHub上运行代码(https://github.com/AayushKrChaudhary/RITnet
我没有得到OpenEDS的语义分割数据集,所以我尝试从互联网上下载png图像,并将其放入Semantic_Segmentation_Dataset\test\中运行测试程序。
该代码给出以下错误:

Traceback (most recent call last):
  File "test.py", line 59, in <module>
    for i, batchdata in tqdm(enumerate(testloader),total=len(testloader)):
  File "C:\Users\b0743\AppData\Local\Continuum\anaconda3\envs\Machine_Learning\lib\site-packages\torch\utils\data\dataloader.py", line 291, in __iter__
    return _MultiProcessingDataLoaderIter(self)
  File "C:\Users\b0743\AppData\Local\Continuum\anaconda3\envs\Machine_Learning\lib\site-packages\torch\utils\data\dataloader.py", line 737, in __init__
    w.start()
  File "C:\Users\b0743\AppData\Local\Continuum\anaconda3\envs\Machine_Learning\lib\multiprocessing\process.py", line 105, in start
    self._popen = self._Popen(self)
  File "C:\Users\b0743\AppData\Local\Continuum\anaconda3\envs\Machine_Learning\lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Users\b0743\AppData\Local\Continuum\anaconda3\envs\Machine_Learning\lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "C:\Users\b0743\AppData\Local\Continuum\anaconda3\envs\Machine_Learning\lib\multiprocessing\popen_spawn_win32.py", line 65, in __init__
    reduction.dump(process_obj, to_child)
  File "C:\Users\b0743\AppData\Local\Continuum\anaconda3\envs\Machine_Learning\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
TypeError: can't pickle cv2.CLAHE objects

(Machine_Learning) C:\Users\b0743\Downloads\RITnet-master\RITnet-master>Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\b0743\AppData\Local\Continuum\anaconda3\envs\Machine_Learning\lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "C:\Users\b0743\AppData\Local\Continuum\anaconda3\envs\Machine_Learning\lib\multiprocessing\spawn.py", line 115, in _main
    self = reduction.pickle.load(from_parent)
EOFError: Ran out of input

字符串
我的环境是:

# Name                    Version                               
cudatoolkit               10.1.243             
cudnn                     7.6.5                         
keras-applications        1.0.8                    
keras-base                2.3.1                   
keras-gpu                 2.3.1                      
keras-preprocessing       1.1.0                                              
matplotlib                3.3.1                         
matplotlib-base           3.3.1                     
numpy                     1.19.1           
numpy-base                1.19.1                            
opencv                    3.3.1                                   
pillow                    7.2.0                                    
python                    3.6.10                            
pytorch                   1.6.0                                   
scikit-learn              0.23.2          
scipy                     1.5.2                                               
torchsummary              1.5.1                  
torchvision               0.7.0                   
tqdm                      4.48.2


我不知道这是不是一个愚蠢的问题,但我希望有人能帮我回答。

yqlxgs2m

yqlxgs2m1#

我真的只是进入了数据集python文件,并注解了所有需要opencv的部分。结果它工作,但你不会得到甜蜜的clahe和其他东西,但它的工作。如果你不需要数据集的东西只是使Tensor的640乘400图像,并把它放在一个空数组,并把该数组在一个数组,直到你有一个4dTensor,并通过它在dnn,然后将输出通过get predictions函数和viola得到一个眼睛特征数组。

kq0g1dla

kq0g1dla2#

我遇到了同样的错误,发现将下面的行从init移动到getitem解决了这个问题。
self.clahe = cv2.clahe CLAHE(clipLimit=1.5,tileGridSize=(8,8))

相关问题