数据增强库Augmentor使用教程

 

 

Augmentor:数据增强工具库

github地址:https://github.com/mdbloice/Augmentor

一.安装:

pip install Augmentor

二.使用:

1.载入包,设置路径:

import Augmentor 
p=Augmentor.Pipeline("./test")

回车之后,默认会生成输出的路径,在./test/output下,output文件夹自动生成,不需要自己新建。

2.图片逆时针随机旋转90度(随机概率可自行设定),p.sample(200)指生成200张这样操作的图片,这条语句可以在指定所有操作之后再运行,否则只会进行旋转90度这个操作

p.rotate90(probability=0.5)
p.sample(200)

3.图片顺时针随机旋转90度(随机概率可自行设定)

p.rotate270(probability=0.5)
p.sample(200)

4 .不固定角度微小旋转:比如向左最大旋转25度,向右最大旋转10度(备注:旋转最大角度范围是0-25度)

p.rotate(probability=0.5,max_left_rotation=25,max_right_rotation=10)
p.sample(200)

5.透视形变-垂直方向形变:magnitude取(0,1),指的是形变程度

p.skew_tilt(probability=0.7,magnitude=1)
p.sample(200)

6.透视形变-斜四角形变形变:magnitude取(0,1),指的是形变程度

p.skew_corner(probability=0.7,magnitude=1)
p.sample(200)

7.弹性扭曲,类似区域扭曲的感觉

p.random_distortion(probability=1,grid_height=5,grid_width=16,magnitude=8)
p.sample(200)

8.错切变换

p.shear(probability=1,max_shear_left=15,max_shear_right=15)
p.sample(200)

9.随机区域擦除

p.random_erasing(probability=1,rectangle_area=0.5)
p.sample(200)

 

10.组合上述操作的增强

import Augmentor 
p=Augmentor.Pipeline("./test")
p.random_erasing(probability=1,rectangle_area=0.5)
p.random_distortion(probability=1,grid_height=5,grid_width=16,magnitude=8)
p.shear(probability=1,max_shear_left=15,max_shear_right=15)
p.sample(200)

 

评论 9
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值