Skip to content

Run Quantized MobileNet V2 models in Caffe2 and TFLite

sf-wind edited this page Nov 9, 2018 · 4 revisions

Both TFLite and Caffe2 have quantized MobileNet V2 models in their official repositories. Both have official benchmarking binaries and recommended compilation steps. It is straightforward to run the quantized MobileNet V2 models on the phones. Here are the necessary steps to run them.

Clone FAI-PEP. Follow the steps here if you run it for the first time.

Clone pytorch. You can follow this to clone pytorch and install prerequisite.

Clone tflite. You can follow this to clone tflite and install prerequisite.

Run quantized Caffe2 model:

FAI-PEP/benchmarking/run_bench.py \
    -b FAI-PEP/specifications/models/caffe2/mobilenet_v2/mobilenet_v2_quant.json \
    --platform android --screen_reporter \
    --framework caffe2 --repo_dir <cloned pytorch directory>

Run quantized TFLite model:

FAI-PEP/benchmarking/run_bench.py \
    -b FAI-PEP/specifications/models/tflite/mobilenet_v2/mobilenet_v2_1.0_224_quant.json \
    --platform android --screen_reporter \
    --framework tflite --repo_dir <cloned tensorflow directory>

You can easily find the performance metrics in those runs.