51

I have successfully trained an object detection model with TensorFlow with the sample configurations given here: https://github.com/tensorflow/models/tree/master/object_detection/samples/configs

Now I want to fine tune my configuration to get better results. One of the promising options I see in there is "data_augmentation_options" under "train_config". Currently, it looks like this:

train_config: {
  batch_size: 1
  ...
  data_augmentation_options {
    random_horizontal_flip {
    }
  }
}

Are there other options to do random scaling, cropping or tweaking of brightness?

privard
  • 511
  • 1
  • 4
  • 8

1 Answers1

83

The list of options is provided in preprocessor.proto:

NormalizeImage normalize_image = 1;
RandomHorizontalFlip random_horizontal_flip = 2;
RandomPixelValueScale random_pixel_value_scale = 3;
RandomImageScale random_image_scale = 4;
RandomRGBtoGray random_rgb_to_gray = 5;
RandomAdjustBrightness random_adjust_brightness = 6;
RandomAdjustContrast random_adjust_contrast = 7;
RandomAdjustHue random_adjust_hue = 8;
RandomAdjustSaturation random_adjust_saturation = 9;
RandomDistortColor random_distort_color = 10;
RandomJitterBoxes random_jitter_boxes = 11;
RandomCropImage random_crop_image = 12;
RandomPadImage random_pad_image = 13;
RandomCropPadImage random_crop_pad_image = 14;
RandomCropToAspectRatio random_crop_to_aspect_ratio = 15;
RandomBlackPatches random_black_patches = 16;
RandomResizeMethod random_resize_method = 17;
ScaleBoxesToPixelCoordinates scale_boxes_to_pixel_coordinates = 18;
ResizeImage resize_image = 19;
SubtractChannelMean subtract_channel_mean = 20;
SSDRandomCrop ssd_random_crop = 21;
SSDRandomCropPad ssd_random_crop_pad = 22;
SSDRandomCropFixedAspectRatio ssd_random_crop_fixed_aspect_ratio = 23;

You can see the details about each option in preprocessor.py. Arguments can be provided as key-value pairs.

  data_augmentation_options {
    ssd_random_crop {
    }
  }
  data_augmentation_options {
    random_pixel_value_scale {
      minval: 0.6
    }
  }
Najih Km
  • 901
  • 7
  • 6
  • 7
    Are all of these data augmentation operations done sequentially? Can we specify that they be done at random? – Jash Shah May 08 '18 at 09:11
  • Can you also tell us how to use the arguments for `ssd_random_crop_pad` operation? – Jash Shah Jun 10 '18 at 13:08
  • 2
    https://github.com/tensorflow/models/blob/master/research/object_detection/builders/preprocessor_builder_test.py, this file could help who want details of configuration – Raymond Cheng Sep 03 '18 at 09:47
  • 4
    Make sure to check out the preprocessor.proto link. There are a lot more options now. – Devin Haslam Oct 02 '19 at 18:27
  • One question: If I use data augmentation then should I have to take care about label file? Because if augmentation applies random crop or rotation to images then ground truth bounding box doesn't match. Is this handle by tensorflow object detection API? – Saurabh Chauhan Mar 10 '20 at 09:33
  • Thanks! Works! Perfectly! – ambigus9 Sep 11 '20 at 17:07
  • Object Detection API handles that internally. You don't have to worry about the labels. They are also transformed automatically when you apply data augmentation. @SaurabhChauhan – Matt May 11 '21 at 12:24