0

我成功上传了图片和标签(csv)。

for name, labels in df.values:
  print(name)
  imgs = read_given_images("./",name)
  labels = df['labels']
  points = np.array(labels)

我想调整图像大小(标签也会更新)。然后我想把它改成tfrecord。在单个图像上,下面的代码可以正确运行,但是当我在组上运行它时会出错

for img, img_points in zip(imgs,points):
  img_points = img_points.reshape(-1,2)
  visualize_points(img[...,::-1],img_points,radius=3,thickness=3)
  new_img, new_points = resize_with_aspect_ratio(img,224,img_points.flatten())
  new_points = new_points.reshape(-1,2)
  visualize_points(new_img[...,::-1].astype(np.uint8),new_points,radius=2,thickness=2)

错误;

The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

我必须在哪里插入 a.any() 或 a.all() 才能解决此错误?

4

1 回答 1

0

imgs = read_given_images("/content/images2",df.names.values)
points = df['labels'].values
points = np.array(points)

错误在 zip 中,我导入了 zipfile。这是我不应该的。python是内置的这个功能。谢谢。

于 2020-07-15T10:28:49.107 回答