For Object Detection via the Tensorflow API using the model_main.py, when I use i.e. random_horizontal_flip in the data_augmentation_options in the train_config of my pipeline.config, are my bounding boxes also affected? This is very important, as otherwise these options are not applicable. This is the same question, but it was not properly answered.
Add a comment
|
1 Answer
Yes, the bounding boxes are affected in the same way.
Specifically for random_horizontal_flip, you can verify it by looking at the function, which also receives boxes.
Flipping the bounding boxes is performed here.
Note not all augmentation options need bounding box altering, but those who do - alter the bounding box accordingly.
5 Comments
Jay Carraway
Thank you for your answer @netanel-sam. I could also find the corresponding function in the preprocessor.py, but I was not able to find the part where this information is passed into the function
random_horizontal_flip. Do you know where exactly this happens?netanel-sam
It happens here: github.com/tensorflow/models/blob/master/research/….
func is a preprocessing function (iterated over all preprocess_options), args is the arguments to the preprocessing function such as image, bounding boxes, masks, etc. params is parameters to a preprocessing function, e.g. scaling ratio, cropping parameters etc. In case of random_horizontal_flip there aren't interesting ones (keypoint permutation).Jay Carraway
Okay, and where are these
preprocess_options defined? I can't even find the place where the preprocessor.py is called at all. I have a really hard time navigating through all these connected scripts. I did a 'usage search' with my IDE and it couldn't find any usage of the preprocessor.py as well as the preprocess function. I could follow the path of the pipeline.config in the model_main.py and where it gets processed into the train_and_eval_dict and then via the model_lib.create_train_and_eval_specs into train_spec where I suppose the information for the data augmentation is.Jay Carraway
But that's pretty much where it ends.
train_spec is then fed into the tf.estimator.train_and_evaluatebut I cannot find anything about the preprocessing there.netanel-sam
It is indeed hard to navigate. You should delve in inputs.py. The function
augment_input_data receives the tensor which contains the data (images, labels, etc), and the augmentation options, and then applies them in github.com/tensorflow/models/blob/master/research/…. This function is called by transform_and_pad_input_data_fn which reads the data augmentation options right from the train config file, and creates data_augmentation_fn which is then used as part of the all transformations to the input data.