In this lab, we are going to use the Model Downloader to download a Tensorflow* Object Detection model - ssd_mobilenet_v1_coco from Open Model Zoo. Then use Model Optimizer to convert the model into Intermediate Representation format with both FP32 and FP16 data precision.
In this section, you will use the Model Downloader to download a public pre-trained Tensorflow* Object Detection model. The ssd_mobilenet_v1_coco model is one of supported Frozen Topologies from TensorFlow Object Detection Models Zoo.
cd /opt/intel/openvino_2021/deployment_tools/open_model_zoo/tools/downloader/
python3 downloader.py -h
python3 downloader.py --print_all
python3 downloader.py --name ssd_mobilenet_v1_coco -o /opt/intel/workshop
cd /opt/intel/workshop/public/ssd_mobilenet_v1_coco/ssd_mobilenet_v1_coco_2018_01_28
ls
You will see the downloaded Tensorflow* model:
checkpoint model.ckpt.data-00000-of-00001 model.ckpt.meta saved_model
frozen_inference_graph.pb model.ckpt.index pipeline.config
To learn more about this model, you can either click HERE, or:
cd /opt/intel/openvino_2021/deployment_tools/open_model_zoo/models/public/ssd_mobilenet_v1_coco
gedit ssd_mobilenet_v1_coco.md
Note: From the model description file, you will need to understand the input and output layer name, shape of the input layer, color order and mean value or scale value if applicable for this model.
In this session, you will use the Model Optimizer to convert the downloaded Tensorflow* Object Detection model to IR format with both FP32 and FP16 data precisions.
cd /opt/intel/openvino_2021/deployment_tools/model_optimizer/
python3 mo.py -h
A list of general parameters for Model Optimizer will be printed out, to learn more about each parameter, you can refer to this Document
To learn more about which and why below Model Optimizer parameters are used for Converting TensorFlow* Object Detection API Models, please refer to Converting TensorFlow* Object Detection API Models from OpenVINO documentation.
For the model downloaded from Open Model Zoo, you can always find a model.yml file which contains the Model Optimizer parameters required to convert this particular model.
python3 mo.py \
--reverse_input_channels \
--input_shape=[1,300,300,3] \
--input=image_tensor \
--output=detection_scores,detection_boxes,num_detections \
--transformations_config=/opt/intel/openvino_2021/deployment_tools/model_optimizer/extensions/front/tf/ssd_v2_support.json \
--tensorflow_object_detection_api_pipeline_config=/opt/intel/workshop/public/ssd_mobilenet_v1_coco/ssd_mobilenet_v1_coco_2018_01_28/pipeline.config \
--input_model=/opt/intel/workshop/public/ssd_mobilenet_v1_coco/ssd_mobilenet_v1_coco_2018_01_28/frozen_inference_graph.pb \
--data_type FP32 \
-o /opt/intel/workshop/Mobilenet-SSD-v1/FP32 \
--model_name mobilenet-ssd-v1-fp32
cd /opt/intel/workshop/Mobilenet-SSD-v1/FP32
ls
You will see three fils were created under this folder, the .xml file is the topology file of the model, while the .bin file is the weight and bias.
mobilenet-ssd-v1-fp32.bin mobilenet-ssd-v1-fp32.mapping mobilenet-ssd-v1-fp32.xml
cd /opt/intel/openvino_2021/deployment_tools/model_optimizer/
python3 mo.py \
--reverse_input_channels \
--input_shape=[1,300,300,3] \
--input=image_tensor \
--output=detection_scores,detection_boxes,num_detections \
--transformations_config=/opt/intel/openvino_2021/deployment_tools/model_optimizer/extensions/front/tf/ssd_v2_support.json \
--tensorflow_object_detection_api_pipeline_config=/opt/intel/workshop/public/ssd_mobilenet_v1_coco/ssd_mobilenet_v1_coco_2018_01_28/pipeline.config \
--input_model=/opt/intel/workshop/public/ssd_mobilenet_v1_coco/ssd_mobilenet_v1_coco_2018_01_28/frozen_inference_graph.pb \
--data_type FP16 \
-o /opt/intel/workshop/Mobilenet-SSD-v1/FP16 \
--model_name mobilenet-ssd-v1-fp16
cd /opt/intel/workshop/Mobilenet-SSD-v1/FP16
ls
You will see three fils were created under this folder, the .xml file is the topology file of the model, while the .bin file is the weight and bias.
mobilenet-ssd-v1-fp16.bin mobilenet-ssd-v1-fp16.xml mobilenet-ssd-v1-fp16.mapping
To learn more about converting a Tensorflow* model using Model Optimizer, please refer to this OpenVINO documentation Converting a Tensorflow* Model