NOTE:On the tensorflow github there are multiple model versions available for MobileNet_v1. The intention is to provide different options to fit various latency and size budgets. For this tutorial mobilenet_v1_1.0_224 is used. For a brief explanation of the naming convention:
v1 - model release version
1.0 - model size (determined by alpha parameter)
224 - input image size (224 x 224pixels)
Convert Mobilenet v1 Tensorflow Model to TF Lite
Create ‘convert.py’ python script in folder '~/tf_convert:'
Expected output: tflite model is created 'converted_model.tflite'
NOTE: notice that after quantization the model size was reduced ~x4 times in moving from 32-bits to 8-bit.
How to obtain input_arrays and output_arrays for conversion
This tutorial describes two ways to obtain this data: using tensorflow API to inspect the model and dump the information OR using a GUI tool to visualize and inspect the model. Both will be detailed in the following sections.
Method 1 - programmatically using Tensorflow API to dump the model graph operations in a file
Download and run the following script to dump the operations in the model:
Loaded model converted_model.tflite resolved reporter invoked average time: 571.325 ms 0.786024: 653 military uniform 0.0476249: 466 bulletproof vest 0.0457234: 907 Windsor tie 0.0245538: 458 bow tie 0.0194905: 514 cornet