wanji / caffe-augmentation

:zap: Caffe real-time data augmentation on-the-fly!!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

caffe-augmentation

Caffe with real-time data augmentation on-the-fly!!!

Introduction

Data augmentation is a simple yet effective way to enrich training data. However, we don't want to re-create a dataset (such as ImageNet) with more than millions of images every time when we change our augmentation strategy. To address this problem, this project provides real-time training data augmentation. During training, caffe will augment training data with random combination of different geometric transformations (scaling, rotation, cropping), image variations (blur, sharping, JPEG compression), and lighting adjustments.

Realtime data augmentation

Realtime data augmentation is implemented within the ImageData layer. We provide several augmentations as below:

  • Geometric transform: random flipping, cropping, resizing, rotation
  • Smooth filtering
  • JPEG compression
  • Contrast & brightness adjustment

How to use

You could specify your network prototxt as:

layer {
name: "data"
type: "ImageData"
top: "data"
top: "label"
include {
  phase: TRAIN
}
transform_param {
  mirror: true
  crop_size: 227
  mean_file: "/home/your/imagenet_mean.binaryproto"
  contrast_adjustment: true
  smooth_filtering: true
  jpeg_compression: true
  rotation_angle_interval: 30
  display: true
}
image_data_param {
  source: "/home/your/image/list.txt"
  batch_size: 32
  shuffle: true
  new_height: 256
  new_width: 256
}
}

You could also find a toy example at /examples/SSDH/train_val.prototxt

Setup caffe-augmentation

Adjust Makefile.config and simply run the following commands:

$ make all -j8
$ make test -j8
$ make runtest -j8

For a faster build, compile in parallel by doing make all -j8 where 8 is the number of parallel threads for compilation (a good choice for the number of threads is the number of cores in your machine).

Acknowledgment

This project is based upon @ChenlongChen's caffe-windows, @ShaharKatz's Caffe-Data-Augmentation, and @senecaur's caffe-rta. Thank you for your inspiration!

About

:zap: Caffe real-time data augmentation on-the-fly!!

License:Other


Languages

Language:C++ 80.4%Language:Python 8.4%Language:Cuda 4.5%Language:CMake 3.0%Language:Protocol Buffer 1.5%Language:MATLAB 1.2%Language:Makefile 0.7%Language:Shell 0.3%Language:Gnuplot 0.0%Language:M 0.0%