Converting model to MyriadX blob¶
To allow DepthAI to use your custom trained models, you need to convert them into a MyriadX blob file format - so that they are optimized for the best inference on MyriadX VPU processor.
There are two conversion steps that have to be taken in order to obtain a blob file:
Use Model Optimizer to produce OpenVINO IR representation (where IR stands for Intermediate Representation)
Use Model Compiler to convert IR representation into MyriadX blob
Image below (from OpenCV Courses site) shows these steps
Below, please find instructions on how to perform these steps using different methods
If you want to perform model conversion and compilation, you can follow:
Using Google Colab¶
You can also train and convert models using Google Colab notebook. You can take a look at our Custom training page, where every tutorial contains also conversion & compilation steps performed directly inside the notebooks.
An example notebook with the compilation steps is here
Using online converter¶
You can also visit our online MyriadX Blob converter that allows specifying different OpenVINO target versions and supports conversions from TensorFlow, Caffe, OpenVINO IR and OpenVINO Model Zoo
Using blobconverter package¶
For automated usage of our blobconverter tool, we have released a blobconverter PyPi package, that allows compiling MyriadX blobs both from the command line and from the Python script directly.
Install and usage instructions can be found here
When converting your model to the OpenVINO format or compiling it to a
.blob, you might come across an issue. This usually
means that a connection between two layers is not supported or that the layer is not supported.
For visualization of NN models we suggest using Netron app.
When converting your model to OpenVINO’s IR format (
.xml), you have to check if the OpenVINO supports layers
that were used. Here are supported layers and their limitations for
TensorFlow 2 Keras,
Unsupported layer type “layer_type”¶
When using compile_tool to compile from IR (.xml/.bin) into .blob, you might get an error like this:
Failed to compile layer "Resize_230": unsupported layer type "Interpolate"
This means that the layer type is not supported by the VPU (Intels Myriad X). You can find supported OpenVINO layers by the VPU here, under the Supported Layers header, in the third column (VPU). Refer to official Intel’s troubleshooting docs for more information.
Incorrect data types¶
If the compiler returns something along the lines of “check error: input #0 has type S32, but one of [FP16] is expected”,
it means that you are using incorrect data types. In the case above, an INT32 layer is connected to FP16 directly.
There should be a conversion in between these layers, and we can achieve that by using the OpenVINOs Convert
layer between these two layers. You can do that by editing your models
.xml and adding the Convert
layer. You can find additional information on this discord thread.
We’re always happy to help with development or other questions you might have.