为什么在使用托盘数据集进行图像分割时,在 pytorch Dataset.__getitem__ 上出现 NotImplementedError?

问题描述 投票:0回答:0

这里有什么问题?我正在使用托盘数据集进行图像分割。但是在可视化中,我得到了错误。这是代码:

for label in CLASSES:
      dataset= Dataset(x_test_dir, y_test_dir, classes= [label])
      image, mask= dataset[2]
      visualize(
          image= image, mask= mask.squeez(), 
          label= label)pe here

我收到这个错误:

[0]
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-23-c3e6816b3e09> in <cell line: 1>()
      1 for label in CLASSES:
      2       dataset= Dataset(x_test_dir, y_test_dir, classes= [label])
----> 3       image, mask= dataset[2]
      4       visualize(
      5           image= image, mask= mask.squeez(),

/usr/local/lib/python3.9/dist-packages/torch/utils/data/dataset.py in __getitem__(self, index)
     51 
     52     def __getitem__(self, index) -> T_co:
---> 53         raise NotImplementedError
     54 
     55     def __add__(self, other: 'Dataset[T_co]') -> 'ConcatDataset[T_co]':

NotImplementedError: 

我正在使用 google colab。我完全根据教程编写代码。所以,我不知道为什么会出错。

python deep-learning pytorch image-segmentation
© www.soinside.com 2019 - 2024. All rights reserved.