I'm trying to use the image_classifier from mediapipe_model_maker to train a custom tflite image classification model. All I see for data augmentation is a boolean that can be passed in the options called "do_data_augmentation" that does random augmentation (cropping, flipping, etc.).
spec = image_classifier.SupportedModels.MOBILENET_V2
hparams=image_classifier.HParams(epochs=100, export_dir="exported_model_2",do_data_augmentation=False)
options = image_classifier.ImageClassifierOptions(supported_model=spec, hparams=hparams)
model = image_classifier.ImageClassifier.create(
train_data = train_data,
validation_data = validation_data,
options=options,
)
I want to be specific about the data augmentation and keep only flipping, exposure and blur. Is that possible? Thanks.
At this date (latest version 0.10.9
), specifying custom augmentation is not possible (or not straightforward).
The flag set in the HParams
object is used to set the augmentation flag for the ImagePreprocessor
. To specify custom augmentations, you would have to subclass the ImageClassifier
to include your own logic, or to fork mediapipe and change the Preprocessor
with your augmentations.
Looking at the code, the augmentations consist of:
tf.image.random_flip_left_right
)tf.image.sample_distorted_bounding_box
)There is no exposure/blurring augmentation available in mediapipe. You would have to add that yourself.