7

I've been hand-rolling augmenters using imgaug, as I really like some of the options that are not available in the tf object detection api. For instance, I use motion blur because so much of my data has fast-moving, blurry objects.

How can I best integrate my augmentation sequence with the api for on-the-fly training?

E.g., say I have an augmenter:

aug = iaa.SomeOf((0, 2), 
                 [iaa.Fliplr(0.5), iaa.Flipud(0.5), iaa.Affine(rotate=(-10, 10))])

Is there some way to configure the object detection api to work with this?

What I am currently doing is using imgaug to generate (augmented) training data, and then creating tfrecord files from each iteration of this augmentation pipeline. This is very inefficient as I am saving large amounts of data to disk rather than running augmentation on the fly, during training.

M.Innat
  • 8,673
  • 5
  • 27
  • 46
eric
  • 4,533
  • 8
  • 49
  • 106
  • 1
    In principle you could modify the preprocessing function to add the transformations that you want, but the problem is that library implements augmentations in NumPy, whereas augmentations in the TF object detection API are implemented in TensorFlow. So you would have to use something like `tf.py_func`, which may not be very efficient. – jdehesa Sep 18 '19 at 12:06
  • Frankly if someone has a solution using tf.py_func that would be great. It would be more efficient than what I'm doing now. I've been looking at the `preprocessing.py` module maybe that's the place to push this., – eric Sep 18 '19 at 23:07
  • What are the augmentation operations that you would like to have? Would implementing them in TF be an option? – rvinas Sep 24 '19 at 07:10
  • One of the important ones is motion blur, most of the others are pretty standard. I guess a new question would be how do I implement one in TF in a way that integrates with the object detection api? I think it is in `preprocessing.py`. Frankly I was expecting integrating imgaug with TF api to be simple, thought I was just missing some standard trick. – eric Sep 24 '19 at 14:46
  • One way to go is to produce a new dataset with only imgaug and turn off tf's online train augmentations – denisb411 Jan 18 '21 at 18:43

1 Answers1

0

Someone has made a repo for this:
https://github.com/JinLuckyboy/TensorFlowObjectDetectionAPI-with-imgaug

Sorry this is not a code answer and I have not actually looked into it, so I will not mark this as officially answered. If I ever get a chance to test it I will let people know.

eric
  • 4,533
  • 8
  • 49
  • 106