数据增强增广方法及实现

数据增强(增广)

在进行图像分类或者检测时候,如果数据量比较少的情况下,可以对已有的图像数据进行一些处理来扩充数据集大小。

分类

对于图像分类而言,可以有的操作有翻转,随机裁剪,随机亮度变化,随机对比度变化,随机旋转等,而标签保持不变;

在tensorflow中有一些封装好的处理函数,比如在cifar10_input.py中就有使用到如下几个:

  • tf.image.random_crop: 对图像随机裁剪
  • tf.image.random_flip_left_right:随机左右翻转
  • tf.image_random_brightness: 随机亮度变化
  • tf.image_random_contrast:随机对比度变化
  • tf.image_per_image_standardization: 减去均值像素,并除以像素方差(图片标准化)
  height = IMAGE_SIZE
  width = IMAGE_SIZE

  # Image processing for training the network. Note the many random
  # distortions applied to the image.

  # Randomly crop a [height, width] section of the image.
  distorted_image = tf.random_crop(reshaped_image, [height, width, 3])

  # Randomly flip the image horizontally.
  distorted_image = tf.image.random_flip_left_right(distorted_image)

  # Because these operations are not commutative, consider randomizing
  # the order their operation.
  distorted_image = tf.image.random_brightness(distorted_image,
                                               max_delta=63)
  distorted_image = tf.image.random_contrast(distorted_image,
                                             lower=0.2, upper=1.8)

  # Subtract off the mean and divide by the variance of the pixels.
  float_image = tf.image.per_image_standardization(distorted_image)

检测

对于检测而言,涉及到旋转操作到,要注意标签的改变。其他操作等标签基本上保持一致即可。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

uncle_ll

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值