3

It is possible to augment images in tensorflow object detection api config files, e.g.:

data_augmentation_options {
  random_horizontal_flip {
  }
}
data_augmentation_options {
  ssd_random_crop {
  }
}

How can I visualize the training images to inspect the results of the augmentation?

Thank you for your help.

user2672299
  • 414
  • 2
  • 12

2 Answers2

5

Here is the code to achieve what has been asked in the question https://github.com/majrie/visualize_augmentation/blob/master/visualize_augmentation.ipynb .

It is based on the answer of @danyfang.

user2672299
  • 414
  • 2
  • 12
4

I suggest you look at input_test.py file, specifically the function test_apply_image_and_box_augmentation in class DataAugmentationFnTest. You can add the data_augmentation_options there and pass your image to the tensor_dict. To visualize it, you can call matplotlib function after sess.run() as augmented_tensor_dict_out can be passed as input argument.

Danny Fang
  • 3,843
  • 1
  • 19
  • 25
  • Thank you that helped a lot. However, preprocessor.py is also normalizing the image. Can I disable it or restore the values before normalization and still keep the augmentation? – user2672299 Mar 06 '19 at 16:06
  • I've found in `https://github.com/tensorflow/models/blob/master/research/object_detection/core/preprocessor_test.py` there exist test code for each individual augmentation option. I think this could fit your goal more precisely. – Danny Fang Mar 07 '19 at 16:29