Changing augmentation parameters in TFOD API

I am aware of the preprocessing proto that is used in the models repo:

My question is how one configures their augmentation pipeline when using the TFOD API. Consider this configuration file. It has a field for augmentation:

train_config: {
  ...
  data_augmentation_options {
    random_horizontal_flip {
    }
  }

If I wanted to expand the set of augmentation transformations here what should I do?

@Laurence_Moroney @khanhlvg any pointers?

Interesting.

This looks like they’ve re-encoded something like keras’s model.get_config, as a proto.

To change the data-augmentation, you edit that data_augmentation_options list.

The .proto files define what’s allowed. The definition of TrainConfig is here:

data_augmentation_options is a repeated PreprocessingStep.

A PreprocessingStep is one of the items from that list. The parameters of each and their default values are defined in preprocessor.proto

If you want to add a RandomScale step:

train_config: {
  ...
  data_augmentation_options {
    random_horizontal_flip {
    }
   random_image_scale {
       min_scale_ratio: 0.9
       max_scale_ratio: 1.1
    }
  }
}

That format is “proto-text” (.PBTXT), you can check your syntax with:

from google.protobuf import text_format

train_config = TrainConfig()
train_config = text_format.Parse(
        r"""
        train_config: {
          ...
          data_augmentation_options {
            random_horizontal_flip {
            }
           random_image_scale {
               min_scale_ratio: 0.9
               max_scale_ratio: 1.1
            }
          }
        }
        """, train_config)
print(train_config)
2 Likes

Wonderful. Thanks for the detailed explanation.

1 Like

Hello, how do you import TrainConfig() in order to do train_config = TrainConfig() please ?