即使在专辑中分配标签字段,“label_fields”也无效

问题描述 投票:0回答:2

我正在使用带有以下代码的albumentations:

 augmentor = alb.Compose([alb.RandomCrop(width=450, height=450),
                             alb.HorizontalFlip(p=0.5),
                             alb.RandomBrightnessContrast(p=0.2),
                             alb.RandomGamma(p=0.2),
                             alb.RGBShift(p=0.2),
                             alb.VerticalFlip(p=.5)],
                             bbox_params=alb.BboxParams(format='albumentations', label_fields=['person']))

"intermediary image-loading code"

img = pyplot.imread("path")
coords = [1,2,3,4]
try:
    augmented = augmentor(image=img, bboxes=[coords], class_labels=['person'])

except Exception as e:
    print(e)

我得到了例外:

Your 'label_fields' are not valid - them must have same names as params in dict

我在网上查了一下,发现其他人也有同样的问题,但从未找到具体的解决方案。我还查看了 documentation,但我无法解读

data
与我的问题有何关联。任何对此的帮助将不胜感激!

此外,由于某种原因,按“tab”键在此网站上不起作用,因此缩进可能会关闭。

machine-learning deep-learning computer-vision data-augmentation albumentations
2个回答
0
投票

我有点傻。

label_fields=['person']
需要改为
label_fields=['class_labels']

此外,

[1,2,3,4]
也未按照
albumentations
格式所需的格式进行标准化。它纯粹只是作为实际列表的占位符。


0
投票
import numpy as np
import albumentations as A

category_id = [0, 1, 2] 
bbox = [[1,2,3,4], [4,5,6,7], [8,9,10,11]]

trans = A.Compose([
    A.HorizontalFlip(p=0.5), 
], bbox_params=A.BboxParams(format='coco', label_fields=['any_name']))

augmented = trans(image=np.array(image), bboxes=bbox, any_name=category_id)

我花了一段时间才意识到问题是 bbox_params 中的 label_fields 参数需要与使用的密钥匹配。 “由“any_name”注明“

只是想记录下来,以防其他人对这些参数遇到同样的困惑。

© www.soinside.com 2019 - 2024. All rights reserved.