README_Albumentations

一、文档:

GitHub: https://github.com/albumentations-team/albumentations

官方文档:Albumentations Documentation

二、Installation

pip install -U albumentations

三、Keypoints augmentation Example:

1. Import the required libraries

import albumentations as A

import cv2

2. Define an 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 =False))

#对图片的操作放在第一个参数的列表中,可支持多种操作,p参数表示进行该操作的概率。

#A.KeypointParams()中,format参数定义ground_truth的坐标点格式,还有“yx”、“xysa”等;label_fields定义ground_truth中标签的名称,此参数是一个列表,可以设置多个标签;remove_invisible参数用来设置是否移除数据增强后超出图片范围的点,默认为True,若为True则不显示不可见的点,若为False则显示不可见的点

3. Read images, keypoints and class_labels

image = cv2.imread("/path/image.jpg")

#image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

keypoints = [

    (264, 203),

    (86, 88),

    (254, 160),

    (193, 103),

    (65, 341),

]

#关键点信息以坐标的形式放入一个列表中,格式与format参数设置的格式同步

class_labels = [

    'left_elbow',

    'right_elbow',

    'left_wrist',

    'right_wrist',

    'right_hip',

]

4. Pass an image and keypoints to the augmentation pipeline and receive augmented images and points.

#对数据进行变换

transformed = transform(image=image, keypoints=keypoints, class_labels=class_labels)  

#读取变换后的数据

transformed_image = transformed['image']

transformed_keypoints = transformed['keypoints']

transformed_class_labels = transformed['class_labels']

四、List of augmentations

1、Spatial-level transforms (空间变换)

(1)、仿射变换

  1. Affine(scale=None, translate_percent=None, translate_px=None, rotate=None, shear=None, interpolation=1, mask_interpolation=0, cval=0, cval_mask=0, mode=0, fit_output=False, always_apply=False, p=0.5) -support keypoints

#仿射变换

该变换包括Translation(移动)、Rotation(旋转)、Scaling(缩放)、Shear(剪切为梯形),其中:

scale<

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值