machine-learningdeep-learningcomputer-visiondata-augmentationalbumentations

'label_fields' are not valid even when assigning label fields in Albumentations


I'm using albumentations with the following code:

 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)

I get the exception: Your 'label_fields' are not valid - them must have same names as params in dict

I looked online and found some other people with the same issue but never found a concrete solution. I also looked at the documentation, and I couldn't decipher how data was supposed to relate to my issue. Any help on this would be much appreciated!

Also, for some reason, pressing "tab" doesn't work on this website, so the indentation might be off.


Solution

  • I was a bit stupid. label_fields=['person'] needs to be changed to label_fields=['class_labels']

    Also the [1,2,3,4] aren't normalized as in the format that the albumentations format requires. It's purely just there as a placeholder for an actual list.