我目前正在为一个项目进行一些人工智能研究,为此我必须熟悉一个名为“Pytorch”的框架。这很好,但是按照官方教程(在这里找到)运行代码时出现了问题。
我的想法是从准备好的数据集中分析一组面部特征,然后对其进行某些操作(尚未完成)。但是当我运行这段代码时:
img_name = os.path.join(self.root_dir, self.landmarks_frame.iloc([index, 0])) # At this point 'index' is 0
数据集是这样初始化的:
face_dataset = fDataset(csv_file='faces/face_landmarks.csv', root_dir='faces/')
这就是错误弹出的地方:
for i in range(len(face_dataset)):
sample = face_dataset[i] # <-- right there
这导致了 getter 函数:
def __getitem__(self, index):
img_name = os.path.join(self.root_dir, self.landmarks_frame.iloc([index, 0]))
image = io.imread(img_name)
landmarks = self.landmarks_frame.iloc[index, 1:].as_matrix()
landmarks = landmarks.astype('float').reshape(-1, 2)
sample = {'image': image, 'landmarks': landmarks}
在我的
FaceLandmarksDataset(Dataset):
类中,我只是得到了标题错误。我发现这很奇怪,因为我可以在PyCharm中正常读取数据集:
![Dataset Inspector](https://istack.dev59.com/oMU4C.webp)
有人能帮忙吗? :)
iloc
。 - Daniel Roseman