本文主要是介绍同时增强多个目标:masks, bounding boxes, keypoints,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
参考链接:
Simultaneous augmentation of multiple targets: masks, bounding boxes, keypoints - Albumentations Documentation
Albumentations 可以将相同的一组变换应用于 the input image 和 all the targets 传递到transform:masks, bounding boxes, keypoints。
Step 1. 使用指定边界框和关键点格式的参数定义 Compose
。
transform = A.Compose([A.RandomCrop(width=330, height=330), A.RandomBrightnessContrast(p=0.2)],bbox_params=A.BboxParams(format="coco", label_fields=["bbox_classes"]),keypoint_params=A.KeypointParams(format="xy", label_fields=["keypoints_classes"]),
)
Step 2. 从磁盘加载所有必需的数据。
For example, here is an image from the COCO dataset. that has one associated mask, one bounding box with the class label person
, and five keypoints that define body parts.
An example image with mask, bounding boxes and keypoints
Step 3. 传递所有目标进行转换并接收其增强版本¶
transformed = transform(image=img,mask=mask,bboxes=bboxes,bbox_classes=bbox_classes,keypoints=keypoints,keypoints_classes=keypoints_classes,
)
transformed_image = transformed["image"]
transformed_mask = transformed["mask"]
transformed_bboxes = transformed["bboxes"]
transformed_bbox_classes = transformed["bbox_classes"]
transformed_keypoints = transformed["keypoints"]
transformed_keypoints_classes = transformed["keypoints_classes"]
The augmented version of the image and its targets
这篇关于同时增强多个目标:masks, bounding boxes, keypoints的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!