pytorch在网络训练中,读取数据时出现问题

报错如下:

Starting epoch 1/100.
----------
Traceback (most recent call last):
  File "E:/Sharm Zhao/3D_U-net/train.py", line 89, in <module>
    label_transforms=y_transforms)
  File "E:/Sharm Zhao/3D_U-net/train.py", line 42, in train
    for img,label in dataloader:
  File "C:\Users\admin\Anaconda3\envs\zhimingspace\lib\site-packages\torch\utils\data\dataloader.py", line 819, in __next__
    return self._process_data(data)
  File "C:\Users\admin\Anaconda3\envs\zhimingspace\lib\site-packages\torch\utils\data\dataloader.py", line 846, in _process_data
    data.reraise()
  File "C:\Users\admin\Anaconda3\envs\zhimingspace\lib\site-packages\torch\_utils.py", line 369, in reraise
    raise self.exc_type(msg)
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "C:\Users\admin\Anaconda3\envs\zhimingspace\lib\site-packages\torch\utils\data\_utils\worker.py", line 178, in _worker_loop
    data = fetcher.fetch(index)
  File "C:\Users\admin\Anaconda3\envs\zhimingspace\lib\site-packages\torch\utils\data\_utils\fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "C:\Users\admin\Anaconda3\envs\zhimingspace\lib\site-packages\torch\utils\data\_utils\fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "E:\Sharm Zhao\3D_U-net\dataset.py", line 38, in __getitem__
    img_y = sitk.GetArrayFromImage(sitk.ReadImage(y_path)).transpose((1,2,0))
  File "C:\Users\admin\Anaconda3\envs\zhimingspace\lib\site-packages\SimpleITK\SimpleITK.py", line 8876, in ReadImage
    return _SimpleITK.ReadImage(*args)
RuntimeError: Exception thrown in SimpleITK ReadImage: D:\a\1\sitk\Code\IO\src\sitkImageReaderBase.cxx:99:
sitk::ERROR: The file "E:/Sharm Zhao/3D_U-net/data/Task02_Heart/after_slice/labelsTr/seg-3043.nii" does not exist.

有几个关键的问题:
1、RuntimeError: Caught RuntimeError in DataLoader worker process 0 2、RuntimeError: Exception thrown in SimpleITK ReadImage: D:\a\1\sitk\Code\IO\src\sitkImageReaderBase.cxx:99:
3、sitk::ERROR: The file “E:/Sharm Zhao/3D_U-net/data/Task02_Heart/after_slice/labelsTr/seg-3043.nii” does not exist.

在这个问题上找了好久,一直不知道到底是哪里出错了。。。

最后才发现,我的标签的文件夹的名称是 labelsTs,而不是labelsTr,傻了傻了!!!

你可能感兴趣的:(实验室)