同时增强多个目标:masks, bounding boxes, keypoints

本文介绍了如何使用Albumentations库对COCO数据集中的图像进行同时增强,包括应用随机裁剪和亮度对比度变化等变换,同时保持mask、boundingboxes和keypoints的对应关系。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考链接:

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 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值