class Flowers(data.Dataset):
def __init__(self, txt, transform=None, target_transform=None, loader=default_loader):
super(Flowers, self).__init__()
fh = open(txt, 'r')
images = []
for line in fh:
line = line.strip('\n')
line = line.rsplit()
words = line.split()
words = str(list.split)
images.append((words[0], int(words[1])))
self.imgs = images
self.transform = transform
self.target_transform = target_transform
self.loader = loader
正如上面的代码,我试图通过一个充满路径的文本来读取我的图片数据集。但是,我收到这样的错误:
File "/Users/paulwang/Library/Application Support/JetBrains/PyCharmCE2020.1/scratches/VGGNet.py", line 130, in <module>
train_data = Flowers(txt='/Users/paulwang/Desktop/flower_photos_train/train.txt', transform=transform)
File "/Users/paulwang/Library/Application Support/JetBrains/PyCharmCE2020.1/scratches/VGGNet.py", line 100, in __init__
words = line.split()
AttributeError: 'list' object has no attribute 'split'
我已经经历了一些类似的问题,但我仍然无法弄清楚如何解决这个问题。我真诚地寻求帮助。
至尊宝的传说
相关分类