Image augmentation library in Python-Augmentor使用心得

转载自https://blog.csdn.net/timcanby/article/details/79247603

Augmentor是个增强图像训练数据的库,减少了使用图像库自己编写代码的繁杂工序,能够批量完成图像的旋转,放大,缩小,添加噪音以扩充数据量。接下来结合官方文档介绍下这个库和使用心得。

首先github:https://github.com/mdbloice/Augmentor

DOCs:https://augmentor.readthedocs.io/en/master/userguide/mainfeatures.html#perspective-skewing

安装:

pip install Augmentor

升级:  pip install Augmentor --upgrade  

导入:(导入需要增强数据的目录,这里以该路径下的100张图像初始化)

 

import Augmentor
p = Augmentor.Pipeline("/path/to/images")

然后你就可以使用这个pipeline对象p进行图像变换了:

 

在执行完所需的处理操作后通过:

 

p.sample(10000)

来进行样本的输出(在路径目录上新生成的output文件夹中)

首先是基本的旋转:

 

p.rotate(probability=0.7, max_left=10, max_right=10)
input and output
输入图像输出图像例

其中左右旋转的数值不能超过25,probability参数为生成图像中执行操作图像的比例,当数值为1时全部的生成图像都会进行旋转操作。

 

在0.1.10版本中的旋转区间表示稍微有所变更:

 

p.rotate(probability=1,max_left_rotation=20,max_right_rotation=20)

如图所示为-20,20区间内的随机旋转。

 

透视,形变:

 

p.skew_tilt(probability=1,magnitude=1)

skew_tilt为上下左右方向的垂直型变,参数magnitude为型变的程度(0,1),当设置为1时的随机型变效果如下:

 

 

输入图像输出图像

同理,向四个角形变:

 

p.skew_corner(probability=1,magnitude=1)

如果只想执行其中的某一类型变skew_left_right()#(只左右方向)

 

如果想进行所有方向的随机变化请使用skew()

弹性扭曲:

 

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

参数的不同扭曲程度不同,这里可以通过自己调整达到想要的效果:

 

 

输入图像输出图像

错切变换(shearing):

也就是使图像向某一侧倾斜啦,参数与旋转类似,范围是0-25

 

p.shear(probability=1,max_shear_left=0,max_shear_right=20)

截取(cropping):

当需要截取某一堆数据的某一个区域时不妨试试这个函数:

 

p.crop_by_size(probability=1,width=100,height=100,centre=True)

 

输入图像输出图像

当然还有以下几种截取方式:

 

p.crop_centre()
p.crop_random()

镜像变换:

 

 

p.flip_left_right()
p.flip_random()
p.flip_top_bottom()

这个函数就不放例子了,结合透视型变的话会有很好的变形结果。

 

随机去除:

 

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

这个函数是随机遮盖掉图像中的某一个部分,rectangle_area的变化范围为0.1-1,效果如下:

 

 

输入图像输出图像

怎么样,对于批量处理图像数据来说也是一个不错的选择吧,合理组合这些函数可以输出更多的效果,例如:

 

p=Augmentor.Pipeline('/')

p.random_distortion(probability=1, grid_width=4, grid_height=4, magnitude=8)

p.rotate(probability=1,max_right_rotation=10,max_left_rotation=10)
p.sample(100)

输出:

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Autoencoder-based data augmentation can have a significant influence on deep learning-based wireless communication systems. By generating additional training data through data augmentation, the performance of deep learning models can be greatly improved. This is particularly important in wireless communication systems, where the availability of large amounts of labeled data is often limited. Autoencoder-based data augmentation techniques can be used to generate synthetic data that is similar to the real-world data. This can help to address the problem of overfitting, where the deep learning model becomes too specialized to the training data and performs poorly on new, unseen data. By increasing the diversity of the training data, the deep learning model is better able to generalize to new data and improve its performance. Furthermore, autoencoder-based data augmentation can also be used to improve the robustness of deep learning models to channel variations and noise. By generating synthetic data that simulates different channel conditions and noise levels, the deep learning model can be trained to be more resilient to these factors. This can result in improved performance in real-world wireless communication scenarios, where channel conditions and noise levels can vary widely. In conclusion, autoencoder-based data augmentation can have a significant influence on deep learning-based wireless communication systems by improving the performance and robustness of deep learning models.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值