|
| 1 | +# Converting GluonCV* Models {#openvino_docs_MO_DG_prepare_model_convert_model_mxnet_specific_Convert_GluonCV_Models} |
| 2 | + |
| 3 | +This document provides the instructions and examples on how to use Model Optimizer to convert [GluonCV SSD and YOLO-v3 models](https://gluon-cv.mxnet.io/model_zoo/detection.html) to IR. |
| 4 | + |
| 5 | +1. Choose the topology available from the [GluonCV Moodel Zoo](https://gluon-cv.mxnet.io/model_zoo/detection.html) and export to the MXNet format using the GluonCV API. For example, for the `ssd_512_mobilenet1.0` topology: |
| 6 | +```python |
| 7 | +from gluoncv import model_zoo, data, utils |
| 8 | +from gluoncv.utils import export_block |
| 9 | +net = model_zoo.get_model('ssd_512_mobilenet1.0_voc', pretrained=True) |
| 10 | +export_block('ssd_512_mobilenet1.0_voc', net, preprocess=True, layout='HWC') |
| 11 | +``` |
| 12 | +As a result, you will get an MXNet model representation in `ssd_512_mobilenet1.0.params` and `ssd_512_mobilenet1.0.json` files generated in the current directory. |
| 13 | +2. Run the Model Optimizer tool specifying the `--enable_ssd_gluoncv` option. Make sure the `--input_shape` parameter is set to the input shape layout of your model (NHWC or NCHW). The examples below illustrates running the Model Optimizer for the SSD and YOLO-v3 models trained with the NHWC layout and located in the `<model_directory>`: |
| 14 | +* **For GluonCV SSD topologies:** |
| 15 | +```sh |
| 16 | +python3 mo_mxnet.py --input_model <model_directory>/ssd_512_mobilenet1.0.params --enable_ssd_gluoncv --input_shape [1,512,512,3] --input data |
| 17 | +``` |
| 18 | +* **For YOLO-v3 topology:** |
| 19 | + * To convert the model: |
| 20 | + ```sh |
| 21 | + python3 mo_mxnet.py --input_model <model_directory>/yolo3_mobilenet1.0_voc-0000.params --input_shape [1,255,255,3] |
| 22 | + ``` |
| 23 | + * To convert the model with replacing the subgraph with RegionYolo layers: |
| 24 | + ```sh |
| 25 | + python3 mo_mxnet.py --input_model <model_directory>/models/yolo3_mobilenet1.0_voc-0000.params --input_shape [1,255,255,3] --transformations_config "mo/extensions/front/mxnet/yolo_v3_mobilenet1_voc.json" |
| 26 | + ``` |
0 commit comments