TensorFlow Lite Model Maker
The TensorFlow Lite Model Maker is a library that simplifies the process of training a TensorFlow Lite model using transfer learning. It's very simple to use and it's very useful for a fast prototyping of a model.
The Object Detection Module of Model Maker, has different EfficientNet versions
Enviroment
The requirements of the TensorFlow Lite Model Maker could be difficult to reproduce in different enviroments. To avoid this, we recommend to use the Dockerfile developed in the proyect: Dockerfile
Usage
As mentioned before, the TensorFlow Lite Model Maker is very simple to use. The following steps are the ones that we used to train a model for the Object Detection Module:
Dataset
The dataset must be in a CSV format, with the following columns format (without headers):
Sample annotation:Training
Import the required libraries:
import numpy as np
import tensorflow as tf
from tflite_model_maker import model_spec
from tflite_model_maker import object_detector
Set Logging Level:
Load the dataset:
Set the model specification:
Train the model:
model = object_detector.create(train_data, model_spec=spec, batch_size=8, epochs=100, train_whole_model=True, validation_data=validation_data)
Evaluate the model:
Export the model:
You could especify the export method for the model in other formats, like TFLite or SavedModel:TFLite:
model.export(export_dir='.', tflite_filename='model.tflite', quantization_config=QuantizationConfig.for_float16(), export_format=[ExportFormat.TFLITE])
SavedModel:
Sample results: