gpt4 book ai didi

python - 类型错误 : unhashable type: 'list' when calling . iloc()

转载 作者:行者123 更新时间:2023-12-02 03:28:48 33 4
gpt4 key购买 nike

我目前正在为一个项目做一些 AI 研究,为此我必须习惯一个名为“Pytorch”的框架。没关系,除了遵循官方教程(找到 here)之外,代码无法正常运行。

我的想法是,我从准备好的数据集中分析一组面部特征,然后用它做一些事情(还没有涉及到那部分)。但是当我运行这段代码时:

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

第一张图片清晰可见的地方。我也检查过它在我正在查找的文件夹中。

有人能帮忙吗? :)

最佳答案

iloc 不需要括号:

self.landmarks_frame.iloc[index, 0]

关于python - 类型错误 : unhashable type: 'list' when calling . iloc(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52428472/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com