Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.

Using MO on model with a custom layer

aag
Novice
425 Views

We've been using OpenVino for a fairly long time, currently using 2021.4. Attempting to upgrade to 2023.0.

One of the models is a YoloV3 model, with a custom output layer. In 2021.4, we implement and deploy a custom layer:
- a `FrontExtractorOp`-derived class in `OV_INSTALL/extensions/front/caffe`
- an `Op`-derived class in `OV_INSTALL/extensions/ops`

where OV_INSTALL is `/opt/intel/openvino_VER/deployment_tools/model_optimizer` or something like it.

We also deploy modified `caffe_pb.py` and `mo_caffe.proto` to `mo/front/caffe/proto`

Again, this is working with 2021.4.

With 2023.0, we no longer rely on Intel's installer; instead we've used `pip3 install openvino-dev[caffe,onnx]==2023.0.0` to obtain MO, with extensions being copied to `$VENVDIR/lib/python3/site-packages/openvino/tools/extensions` and the PBs being copied to `$VENVDIR/lib/python3/site-packages/openvino/tools/mo/front/caffe/proto`. This doesn't work, the error being:

```
wait4(779, [ ERROR ] Exception occurred during running replacer "REPLACEMENT_ID" (<class 'openvino.tools.mo.load.caffe.loader.CaffeLoader'>): Unexpected exception happened during extracting attributes for node detection_out.
Original exception message: Found custom layer "detection_out". Model Optimizer does not support this layer. Please, implement extension.
For more information please refer to Model Optimizer FAQ, question #45. (https://docs.openvino.ai/latest/openvino_docs_MO_DG_prepare_model_Model_Optimizer_FAQ.html?question=45#question-45)
```

Did the extensibility mechanism change in 2023.0? Are the extensions supposed to be placed in a different folder when MO is installed with pip? Do we need to re-implement it and if so, is there a good sample? Most importantly, what changed 2021.4->2023.0 to cause this?

0 Kudos
2 Replies
Wan_Intel
Moderator
402 Views

Dear Aag,

Thanks for reaching out to us.

 

To convert Caffe model with custom layers into Intermediate Representation using OpenVINO™ toolkit 2023, please launch Model Optimizer for Caffe model with custom layers with a specified CustomLayersMapping file.

 

Example of CustomLayersMapping.xml can be found in <OPENVINO_INSTALLATION_DIR>/mo/front/caffe/CustomLayersMapping.xml.example.

 

Optional parameters without default values and not specified by the user in the .prototxt file are removed from the Intermediate Representation, and nested parameters are flattened.

 

Example of launching Model Optimizer for bvlc_alexnet.caffemodel with a specified CustomLayersMapping file:

 

mo --input_model bvlc_alexnet.caffemodel -k CustomLayersMapping.xml --disable_omitting_optional --enable_flattening_nested_params

 

For more information, please refer to Converting a Caffe Model.

 

 

Regards,

Wan

 

0 Kudos
Wan_Intel
Moderator
349 Views

Dear Aag,

Thanks for your question.

Please submit a new question if additional information is required as this thread will no longer be monitored.



Regards,

Wan


0 Kudos
Reply