数据增强论文解读:Random Erasing Data Augmentation

文章目录

  • 前言
  • 一、Introduction
  • 二、Related Work
  • 三、数据集
  • 四、算法
  • 五、实验
  • 六、代码


前言

文章来源:The Thirty-Fourth AAAI Conference on Artificial Intelligence (AAAI-20)
给了代码,包含在两个数据集上的代码


一、Introduction

  • 论文为CNN训练提出了一种新的数据增强方法:Random Erasing
  • 具体方法:
    (1)在一张图片中随机的选择一个矩形框,在随机的位置上使用随机的值(或者- - ImageNet)来擦除图片原来的像素。
    (2)在目标检测中可以分为单独遮蔽目标和遮蔽图像两种。
    (3)可以视为对图像添加块状噪声,会造成像素的损失
    (4)类似dropout舍弃神经元,rondom erasing为舍弃像素点。
  • 实际作用:通过该方法能够给图片加入不同程度的遮挡,通过这样的训练数据,可以减少模型过拟合的风险同时对遮挡具有一定的鲁棒性。随机擦除和random cropping,random flipping一样可以作为数据增强的方法,在分类,检测和行人重识别领域能够取得不错的效果。

二、Related Work

1、防止过拟合方法正则化regularization
2、数据增强data augmentation:两种方法random cropping 和random flipping
3、相关算法
Blockout:在CNN层上设置权重矩阵同时进行正则化和模型选择——RE不需要学习参数
模糊图像抑制softmax学习更显著特征——RE不需要监督信息
消除最具判别性区域,迭代训练(弱监督语义分割)——RE只需要训练一次
A-Fast-RCNN:GAN动态产生难以检测位置的图片——RE计算量小

三、数据集

分类:CIFAR和Fashion-MNIST
目标检测:PASCAL VOC 2007
行人重识别:Market-1501

四、算法

在这里插入图片描述
典型值:在这里插入图片描述

在不同任务中的不同策略:

  • 随机删除图像分类和人物识别
    在这里插入图片描述

  • 目标检测的随机擦除
    1)对整个图像进行擦除和识别:对同一图像进行随机擦除和识别;
    2)对象感知随机擦除(ORE):在每个对象的边界框中选择擦除区域。在后者中,如果图像中有多个对象,则分别对每个对象进行随机擦除。
    3) 图像和对象感知随机擦除(I+ORE):在整个图像和每个对象边界框中选择擦除区域。
    在这里插入图片描述

  • 与random cropping互补
    在这里插入图片描述

五、实验

1、目标检测 slightly better
在这里插入图片描述
2、分类 三种共用最好
通过实验可以发现效果最好的是random cropping方法,其次是random flipping ,最后才是random erasing。但是三种一起使用确实能得到最好的效果。
在这里插入图片描述

六、代码

class RandomErasing(object):""" Randomly selects a rectangle region in an image and erases its pixels.'Random Erasing Data Augmentation' by Zhong et al.See https://arxiv.org/pdf/1708.04896.pdfArgs:probability: The probability that the Random Erasing operation will be performed.sl: Minimum proportion of erased area against input image.sh: Maximum proportion of erased area against input image.r1: Minimum aspect ratio of erased area.mean: Erasing value."""def __init__(self, probability=0.5, sl=0.02, sh=0.4, r1=0.3, mean=(0.4914, 0.4822, 0.4465)):self.probability = probabilityself.mean = meanself.sl = sl  # 初始化可选择的擦除区域面积设置的最小比例self.sh = sh  # 初始化可选择的擦除区域面积设置的最大比例self.r1 = r1  # 初始化最小长宽比def __call__(self, img):if random.uniform(0, 1) >= self.probability:return imgfor attempt in range(100):area = img.size()[1] * img.size()[2]target_area = random.uniform(self.sl, self.sh) * area  # 面积范围[sl, sh]*area=[0.02*area, 0.4*area]aspect_ratio = random.uniform(self.r1, 1 / self.r1)  # 长宽比范围[r1, 1/r1]=[0.3. 3.333...]h = int(round(math.sqrt(target_area * aspect_ratio)))  # 擦除区域高度(height)w = int(round(math.sqrt(target_area / aspect_ratio)))  # 擦除区域宽度(width)if w < img.size()[2] and h < img.size()[1]:x1 = random.randint(0, img.size()[1] - h)  # 随机起始点纵坐标(height方向)y1 = random.randint(0, img.size()[2] - w)  # 随机起始点横坐标(width方向)if img.size()[0] == 3:  # RGB图img[0, x1:x1 + h, y1:y1 + w] = self.mean[0]  # 将擦除区域全部赋予预设小数img[1, x1:x1 + h, y1:y1 + w] = self.mean[1]img[2, x1:x1 + h, y1:y1 + w] = self.mean[2]else:  # 灰度图img[0, x1:x1 + h, y1:y1 + w] = self.mean[0]return imgreturn img


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部