首页 > 解决方案 > 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 不知道这个属性?我该如何解决这个问题?

标签: pythondeep-learningpytorchgoogle-colaboratorydata-augmentation

解决方案


推荐阅读