---
# System prepended metadata

title: mobilenet_ssd_v1 模型轉換

---

# mobilenet_ssd_v1 模型轉換

1. 進入轉換的SDK目錄
`cd /work/SGS_V1_16.04/home/dynacolor/sigma_star//home/dynacolor/sigma_star/SGS_IPU_SDK_v1.1.1_1204/`


2. sigma star detection 的detector 都是backbone detector 分開轉換再合併

` python3 ./Scripts/ConvertTool/ConvertTool.py  tensorflow_graphdef --graph_def_file ./SGS_Models/tensorflow/ssd_mobilenet_v1/ssd_mobilenet_v1.pb --output_file ./ssd_mobilenet_v1_concat.sim --input_arrays normalized_input_image_tensor --output_arrays Squeeze,convert_scores --input_shapes 1,300,300,3 --input_config ./SGS_Models/tensorflow/ssd_mobilenet_v1/input_config_concat.ini`
得到backbone 的模型 `ssd_mobilenet_v1_concat.sim`

3. 轉換ssd detector 部分的模型
`python3 ./Scripts/postprocess/postprocess.py -n ssd_mobilenet_v1_postprocess`
得到`ssd_mobilenet_v1_postprocess.sim`

4. 合併兩個模型
` ./bin/concat_net --mode append --transform ./cfg/CompilerConfig.txt --input_config ./SGS_Models/tensorflow/ssd_mobilenet_v1/input_config.ini --model1 ./ssd_mobilenet_v1_concat.sim --model2 ./ssd_mobilenet_v1_postprocess.sim  --output ./ssd_mobilenet_v1_float.sim`
得到 `ssd_mobilenet_v1_float.sim`
5. 轉換成Fixed model
`python3 /work/SGS_V1_16.04/home/dynacolor/sigma_star/Sigmastar_SDK_v1.0.6/SGS_IPU_SDK_v1.0.6/SGS_IPU_SDK_v1.0.6//Scripts/ConvertTool/ConvertTool.py  tensorflow_graphdef --graph_def_file /work/SGS_V1_16.04/home/dynacolor/sigma_star/Sigmastar_SDK_v1.0.6/SGS_Models/tensorflow/ssd_mobilenet_v1/ssd_mobilenet_v1.pb --output_file ./ssd_mobilenet_v1_concat.sim --input_arrays normalized_input_image_tensor --output_arrays Squeeze,convert_scores --input_shapes 1,300,300,3 --input_config /work/SGS_V1_16.04/home/dynacolor/sigma_star/Sigmastar_SDK_v1.0.6/SGS_Models/tensorflow/ssd_mobilenet_v1/input_config_concat.ini`
6. 轉換成offline model
 ./Scripts/calibrator/calibrator.py  -i ./SGS_Models/resource/detection/coco2017_calibration_set32/ -m ./ssd_mobilenet_v1_float.sim  -c Detection --input_config ./SGS_Models/tensorflow/ssd_mobilenet_v1/input_config.ini -n ssd_mobilenet_v1

7. 測試結果
更改 `-m -t` 的參數分別切換三階段轉出來的模型 `Float Fixed Offline`結果是否近似
如果有不同就知道是哪裡精度掉或是轉錯了
` python3 ./Scripts/calibrator/simulator.py -i /work/SGS_V1_16.04/home/dynacolor/sigma_star/Sigmastar_SDK_v1.0.6/SGS_Models/resource/detection//coco2017_val_set100/000000006409.jpg  -m ./ssd_mobilenet_v1_offline.sim -c Detection -t Offline -n ssd_mobilenet_v1 --draw_result ./`


