博主想使用Unet网络完成一个分割任务,手边只有40张图和对应的mask,需要进行data augment.
做数据增强有很多工具,常用的是使用keras内置的ImageDataGenerator生成器生成图片,但是这个工具只能对一张图进行随机变化,而image和mask是一一对应的,二者必须同时进行同种变化.
下面隆重介绍一个强大的数据增强工具augmentor
它的使用方法十分简单
安装Augmentor
pip install Augmentor
对图片进行随机旋转
import Augmentor
p = Augmentor.Pipeline("/path/to/images")
p.rotate(probability=1, max_left_rotation=5, max_right_rotation=5) #probability表示以一定概率随机处理图片
p.sample(500) #产生500张图片
image and ground truth data can be identically augmented
p = Augmentor.Pipeline("/path/to/images")
# Point to a directory containing ground truth data.