文章目录
- Albumentation
- Classification
- Segmentation
- Detection
- KeyPoints Augmentation
Albumentation
所有实现的变换。
变换以及支持的类型。此处
Classification
- 创建图片扩展流程
使用 Compose
类定义数据增强的流程。Compose
类接受一个包含所有图片变换的列表。
transform = A.Compose([
A.RandomCrop(width=256, height=256),
A.HorizontalFlip(p=0.5),
A.RandomBrightnessContrast(p=0.2),
])
- 读取图片
- 传入图片,获取变换后图片
transformed_image = transform(image=image)["image"]
Segmentation
需要同时变换图片和 Mask 。1,2 两布同 Classification 相同,第三步
- 传入图片和 Mask
transformed = transform(image=image, mask=mask)
transformed_image = transformed['image']
transformed_mask = transformed['mask']
如果传入多个 Mask,采用 transform(image=image, masks=masks
,masks
是 mask
组成的列表。
Detection
四种 bbox 格式:
pascal_voc
:[x_min, y_min, x_max, y_max]
albumentations
:Normalized [x_min, y_min, x_max, y_max]
coco
:[x_min, y_min, width, height]
yolo
:Normalized [x_center, y_center, width, height]
具体流程:
- Augmentaion Pipeline
transform = A.Compose([
A.RandomCrop(width=450, height=450),
A.HorizontalFlip(p=0.5),
A.RandomBrightnessContrast(p=0.2),
], bbox_params=A.BboxParams(format='coco', min_area=1024, min_visibility=0.1, label_fields=['class_labels']))
min_area
is a value in pixels. If the area of a bounding box after augmentation becomes smaller than min_area
, Albumentations will drop that box.
min_visibility
is a value between 0 and 1. If the ratio of the bounding box area after augmentation to the area of the bounding box before augmentation becomes smaller than min_visibility
, Albumentations will drop that box.
label_fields
确定哪些传入参数作为 bbox 的类别。
- Pass Image and labels
下面这个例子中,每个 bbox 有两个类(class_labels
,class_categories
)。
transform = A.Compose([
A.RandomCrop(width=450, height=450),
A.HorizontalFlip(p=0.5),
A.RandomBrightnessContrast(p=0.2),
], bbox_params=A.BboxParams(format='coco', label_fields=['class_labels', 'class_categories'])))
class_labels = ['cat', 'dog', 'parrot']
class_categories = ['animal', 'animal', 'item']
transformed = transform(image=image, bboxes=bboxes, class_labels=class_labels, class_categories=class_categories)
transformed_image = transformed['image']
transformed_bboxes = transformed['bboxes']
transformed_class_labels = transformed['class_labels']
transformed_class_categories = transformed['class_categories']
KeyPoints Augmentation
支持的关键点格式,此处
- Augmentation Pipeline
transform = A.Compose([
A.RandomCrop(width=330, height=330),
A.RandomBrightnessContrast(p=0.2),
], keypoint_params=A.KeypointParams(format='xy', label_fields=['class_labels'], remove_invisible=True, angle_in_degrees=True))
label_fields
:In some computer vision tasks, keypoints have not only coordinates but associated labels as well. (different kinds of keypoints)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)