这里给出一个数据增强包imgaug的应用实例


可以简单修改数据路径即可运行程序,对数据进行增强,可以加上对文件夹下的dataset遍历,批处理数据增强。程序来源于Imgaug的github issues便通过做修改,运行于ubuntu,win10下数据写出有问题:

'see' command line parameter default in ubuntu

import imgaug as ia
from imgaug import augmenters as iaa
import numpy as np
import cv2im = cv2.imread('C:/Users/admin/Desktop/20130201_m007.jpg')
im = cv2.resize(im, (224,224)).astype(np.int8)
images = np.zeros([2,224,224,3])
images[0] = im# Sometimes(0.5, ...) applies the given augmenter in 50% of all cases,
# e.g. Sometimes(0.5, GaussianBlur(0.3)) would blur roughly every second image.
st = lambda aug: iaa.Sometimes(0.3, aug)# Define our sequence of augmentation steps that will be applied to every image
# All augmenters with per_channel=0.5 will sample one value _per image_
# in 50% of all cases. In all other cases they will sample new values
# _per channel_.
seq = iaa.Sequential([iaa.Fliplr(0.5), # horizontally flip 50% of all imagesiaa.Flipud(0.5), # vertically flip 50% of all imagesst(iaa.Superpixels(p_replace=(0, 1.0), n_segments=(20, 200))), # convert images into their superpixel representationst(iaa.Crop(percent=(0, 0.1))), # crop images by 0-10% of their height/widthst(iaa.GaussianBlur((0, 3.0))), # blur images with a sigma between 0 and 3.0st(iaa.Sharpen(alpha=(0, 1.0), )), # sharpen imagesst(iaa.Emboss(alpha=(0, 1.0), strength=(0, 2.0))), # emboss images# search either for all edges or for directed edgesst(iaa.Sometimes(0.5,iaa.EdgeDetect(alpha=(0, 0.7)),iaa.DirectedEdgeDetect(alpha=(0, 0.7), direction=(0.0, 1.0)),)),st(iaa.AdditiveGaussianNoise(loc=0, scale=(0.0, 0.2), per_channel=0.5)), # add gaussian noise to imagesst(iaa.Dropout((0.0, 0.1), per_channel=0.5)), # randomly remove up to 10% of the pixelsst(iaa.Invert(0.25, per_channel=True)), # invert color channelsst(iaa.Add((-10, 10), per_channel=0.5)), # change brightness of images (by -10 to 10 of original value)st(iaa.Multiply((0.5, 1.5), per_channel=0.5)), # change brightness of images (50-150% of original value)st(iaa.ContrastNormalization((0.5, 2.0), per_channel=0.5)), # improve or worsen the contrastst(iaa.Affine(scale={"x": (0.8, 1.2), "y": (0.8, 1.2)}, # scale images to 80-120% of their size, individually per axistranslate_px={"x": (-16, 16), "y": (-16, 16)}, # translate by -16 to +16 pixels (per axis)rotate=(-45, 45), # rotate by -45 to +45 degreesshear=(-16, 16), # shear by -16 to +16 degreesorder=ia.ALL, # use any of scikit-image's interpolation methodscval=(0, 255), # if mode is constant, use a cval between 0 and 255mode=ia.ALL # use any of scikit-image's warping modes (see 2nd image from the top for examples))),st(iaa.ElasticTransformation(alpha=(0.5, 3.5), sigma=0.25)) # apply elastic transformations with random strengths],random_order=True # do all of the above in random order
)images_aug = seq.augment_images(images)
seq.show_grid(images[0], rows=8, cols=8)

imgaug数据增强实例相关推荐

  1. imgaug数据增强神器:第三章 调用多核CPU

    官网:https://imgaug.readthedocs.io/en/latest/ 教程:https://nbviewer.jupyter.org/github/aleju/imgaug-doc/ ...

  2. imgaug数据增强神器:第四章 增强关键点/界标

    官网:https://imgaug.readthedocs.io/en/latest/ 教程:https://nbviewer.jupyter.org/github/aleju/imgaug-doc/ ...

  3. yolo imgaug数据增强 标签同时也增强

    原文:https://blog.csdn.net/m0_37940759/article/details/115212083 完整代码: import xml.etree.ElementTree as ...

  4. imgaug数据增强神器:第二章 随机模式和确定模式

    官网:https://imgaug.readthedocs.io/en/latest/ 教程:https://nbviewer.jupyter.org/github/aleju/imgaug-doc/ ...

  5. imgaug数据增强神器:第一章 加载和增强图像

    官网:https://imgaug.readthedocs.io/en/latest/ 教程:https://nbviewer.jupyter.org/github/aleju/imgaug-doc/ ...

  6. imgaug数据增强

    imgaug数据增强 最近在做目标检测的项目,由于手里的数据无法很好的满足深度学习的要求,所以需要用到数据增强的手段来扩充自己的数据集,这里我采用基于python的imgaug包,具体的调用方法网上都 ...

  7. imgaug数据增强神器:第零章 安装

    官网:https://imgaug.readthedocs.io/en/latest/ 教程:https://github.com/aleju/imgaug-doc/tree/master/noteb ...

  8. imgaug数据增强库中常用的增强器

    Overview of Augmenters: https://imgaug.readthedocs.io/en/latest/source/overview_of_augmenters.html 1 ...

  9. imgaug数据增强神器:第十一章 复制随机状态和使用多个增强序列

    官网:https://imgaug.readthedocs.io/en/latest/ 教程:https://github.com/aleju/imgaug-doc/tree/master/noteb ...

最新文章

  1. MySQL8——源码安装
  2. msbuild FileSysExcludeFiles
  3. 物联网正在给批发业带来新的商业模式
  4. matlab 不单调 插值,三组无关数据进行MATLAB画三维图不采用插值的方法该怎么办...
  5. Python 2.6.2的字节码指令集一览
  6. 博图帮助乱码解决方法
  7. c语言如何在坐标输出,tc 如何在指定坐标处 输出bmp图片??
  8. iis设置首页为main.html,遇到X-Frame-Options头未设置"怎么解决
  9. 苹果mac图像后期处理软件:Lightroom Classic
  10. windows程序设计简介
  11. access 数据库和mysql_access数据库和sql数据库你必须知道的区别
  12. POM文件配置Maven仓库地址
  13. 京瓷4501i打印机扫描步骤_「硬件」如何使用打印机扫描文件传送到电脑本地?...
  14. 可能是最详细的Win10+黑苹果双系统安装教程(For Dell 7580)
  15. 安装程序总是提示重启计算机,技巧| 安装西门子软件时提示重启电脑的解决办法...
  16. C++虚函数、多继承和虚基类学习心得 内存布局
  17. 使用lanyu的激活码,报错1653219,解决办法
  18. Scala中Either两个子类Left/Right
  19. 红黑树与平衡二叉树_百图详解红黑树
  20. zabbix用户和组权限、admin密码的修改

热门文章

  1. 杨辉三角靠左c语言,杨辉三角(空格对齐)
  2. DVI接口详解及信号测试流程
  3. mainui类JAVA什么意思_main ui是什么意思
  4. 人生赢家的12个强大习惯
  5. NOI:1526 宗教信仰
  6. 神经网络权重是什么意思,神经网络如何更新权重
  7. quarts StatefulJob
  8. java 灰度直方图_【数字图像处理】灰度直方图、直方图均衡化、直方图规定化...
  9. win7关闭加域用户下5分钟锁屏
  10. 虚拟机点进服务器鼠标怎么退出来,win10虚拟机切换鼠标怎么操作_win10虚拟机内外鼠标如何切换...