AttributeError:'None Type'对象没有属性'read'

时间:2019-03-31 01:08:37

标签: python image-processing machine-learning

我正在尝试在python的机器学习中执行图像分类任务,但出现以下错误- AttributeError:'NoneType'对象没有属性'read'

class Dataset(data.Dataset):

    def __init__(self, df, transform=None):

        self.df = df
        self.transform = transform

    def __len__(self):

        return len(self.df)

    def __getitem__(self, index):

        a = self.df['path'][index]
        b = int(self.df['cell_type_idx'][index])
        X = Image.open(a)
        y = torch.tensor(b)

        if self.transform:
            X = self.transform(X)

        return X, y

0 个答案:

没有答案