Augmentor和imgaug——python图像数据增强库
Tags: ComputerVision Python
介绍两个图像增强库:Augmentor和imgaug,Augmentor使用比较简单,只有一些简单的操作。 imgaug实现的功能更多,可以对keypoint, bounding box同步处理,比如你现在由一些标记好的数据,只有同时对原始图片和标记信息同步处理,才能有更多的标记数据进行训练。我在segmentation和detection任务经常使用imgaug这个库。
Augmentor
http://augmentor.readthedocs.io/en/master/index.html
Augmentor 是管道化的图像增强库,每一个增强操作都是逐步叠加在图像上。此外对于输入的图像,可以选择按照一定的概率进行增强,比如只随机对一半图像进行旋转。
rotate(probability=0.5, max_left_rotation=5, max_right_rotation=10)
可以实现的操作有, rotate, crop, perspective skew(视角倾斜), elastic distortions(弹性变换), sheering(坐标轴倾斜), mirroring(镜像)
可以使用Augumentor.Pipeline()创建一个实例,调用各种方法向pipeline添加方法, status()可以显示当前pipeline的状态,在status中每个操作都有一个对应的index, remove_operation(index)移除一个操作, 最后调用sample(nums)得到nums个augument后的图像。
import Augmentor
p = Augmentor.Pipeline("/path/to/images/")
p.status()
p.remove_operation(0)
rotate
rotate() 旋转,非90度旋转会带来padding或者裁剪
rotate90()
rotate180()
rotate270()
rotate_random_90() 随机旋转,90, 180, 270
resize
crop
crop_centre()
crop_by_size()
crop_random()
sheer
+ sheer()
mirroring
flip_left_right()
flip_top_bottom()
flip_random()
elastic distortion
random_distortion()
Before