python - 图像和标签循环中的错误值不明确,python
问题描述
我成功上传了图片和标签(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() 才能解决此错误?
解决方案
imgs = read_given_images("/content/images2",df.names.values)
points = df['labels'].values
points = np.array(points)
错误在 zip 中,我导入了 zipfile。这是我不应该的。python是内置的这个功能。谢谢。
推荐阅读
- image - 如何将图像像素转换为 txt 文件中的 HEX 颜色代码?
- php - 为什么我的 SESSION 变量在主机上未定义但在本地未定义
- r - R:如何提高梯度提升模型的拟合度
- r - 如何为 R 中的每个股票价格创建索引值?
- c# - DataTemplate 中的 WPF 绑定用户控件
- c++ - 从文件中提取的字符串未正确计算
- c++ - 如何在 C++ 中优化数组的交换元素
- load-balancing - 负载均衡器如何处理所有服务器都忙的情况?
- javascript - 无论地图视图/缩放如何,如何使用 Google Maps API 一次只能看到 10 个标记
- xamarin.forms - 如何在 Xamarin.Forms 中以编程方式调用 Binding.Path?