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:
// Message for configuring DetectionModel training jobs (train.py).
// Next id: 31
message TrainConfig {
// Effective batch size to use for training.
// For TPU (or sync SGD jobs), the batch size per core (or GPU) is going to be
// `batch_size` / number of cores (or `batch_size` / number of GPUs).
optional uint32 batch_size = 1 [default=32];
// Data augmentation options.
repeated PreprocessingStep data_augmentation_options = 2;
// Whether to synchronize replicas during training.
optional bool sync_replicas = 3 [default=false];
// How frequently to keep checkpoints.
optional float keep_checkpoint_every_n_hours = 4 [default=10000.0];
// Optimizer used to train the DetectionModel.
optional Optimizer optimizer = 5;
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 ?