Converts a SavedModel into Tensorflow Lite format. For details, see Tensorflow Lite Converter

convert_model[source]

convert_model(saved_model_dir)

Convert a SavedModel into Tensorflow Lite Format. saved_model_dir: the path to the SavedModel directory returns: the converted Tensorflow Lite model

save_model[source]

save_model(tflite_model, output_file)

Save a Tensowflow Lite model to disk. tflite_model: the Tensorflow Lite model output_file: the path and filename to save the Tensorflow Lite model

Helper Methods

read_pipeline_config[source]

read_pipeline_config(pipeline_config_path)

Reads the pipeline config file.

pipeline_config_path: The path to the pipeline config file.

configure_logging[source]

configure_logging(logging_level=20)

Configures logging for the system.

logging_level: The logging level to use.

Run from command line

To run from command line, use the following command: python -m mlcore.tensorflow.tflite_converter [parameters]

The following parameters are supported:

  • --source: The path to the folder containing the SavedModel. (e.g.: datasets/image_object_detection/car_damage/saved_model)
  • --categories: The categories file to add to the Tensorflow Lite model. (e.g.: datasets/image_object_detection/car_damage/categories.txt)
  • --name: The name of the model. (e.g.: "SSD MobileNetV2")
  • --version: The version of the model, default to 1 (=v1)
  • --type: The type of the model, if not explicitly set try to infer from categories file path.
  • --output: The folder to store the Tensorflow Lite model. (e.g.: datasets/image_object_detection/car_damage/tflite)