python - AttributeError:“BoundingBoxesOnImage”对象没有属性“项目”
问题描述
我正在解决一个对象检测问题。我的代码在 Jupyter Notebook 中运行没有任何问题。但是当我在 Colab 中运行它时AttributeError
,下一段代码中有一个(它是自定义 Dataset 类的一部分):
from imgaug.augmentables.bbs import BoundingBox, BoundingBoxesOnImage
bb = BoundingBoxesOnImage([BoundingBox(*box_coords)], shape=image.size)
image, box = self.seq(image=np.array(image), bounding_boxes=bb)
# convert box coordinates back to list
new_box_coords = box.items[0].coords.reshape(4).tolist()
其中 seq 是一个增强序列:
seq = imgaug.augmenters.Sequential([
imgaug.augmenters.flip.Fliplr(0.5),
imgaug.augmenters.Affine(rotate=(15, -15))
])
错误是:
'BoundingBoxesOnImage' object has no attribute 'items'.
但是我在 imgaug 文档中找到了一个属性 items。我检查了 imgaug 库的版本:它在本地和 Colab 中都是 0.4.0。为什么 Colab 不知道这个属性?我该如何解决这个问题?
解决方案
推荐阅读
- python - 从多个 Rar 文件中收集评论数据而无需解压缩
- java - 错误 335544421。连接被远程接口拒绝
- c# - 使用 EF Core 加载未映射的属性
- multithreading - 如何同步插入/删除元素到数据结构,功能方式?
- paypal - 字段格式错误:在 payflow pro 中没有 BAID/Account Number/ORIGID 时无法创建 RB Profile
- python - 从宽到长重塑熊猫数据框
- angular - 在 Angular 中以编程方式加载子组件
- java - Activiti 部署、定义、实例、任务和作业之间有什么区别
- java - 在java中查找素数时得到奇怪的输出
- docker - Docker:无法启动 docker 图像/无法添加路径 /etc/