OpenVINO output key error after conversion from ONNX

644 views Asked by At

I've converted a (modified) Darknet model to onnx, (tried opset 10 & 11) and then converting this onnx model into IR using this (at the bottom)

Everything seems to be OK

C:\Program Files (x86)\IntelSWTools\openvino_2020.3.194\deployment_tools\model_optimizer>python mo.py --input_model C:\dev\yolo\weights\export.onnx --progress --output_dir C:\dev\yolo\weights\
Model Optimizer arguments:
Common parameters:
        - Path to the Input Model:      C:\dev\yolo\weights\export.onnx
        - Path for generated IR:        C:\dev\yolo\weights\
        - IR output name:       export
        - Log level:    ERROR
        - Batch:        Not specified, inherited from the model
        - Input layers:         Not specified, inherited from the model
        - Output layers:        Not specified, inherited from the model
        - Input shapes:         Not specified, inherited from the model
        - Mean values:  Not specified
        - Scale values:         Not specified
        - Scale factor:         Not specified
        - Precision of IR:      FP32
        - Enable fusing:        True
        - Enable grouped convolutions fusing:   True
        - Move mean values to preprocess section:       False
        - Reverse input channels:       False
ONNX specific parameters:
Model Optimizer version:
Progress: [....................] 100.00% done
[ SUCCESS ] Generated IR version 10 model.
[ SUCCESS ] XML file: C:\dev\yolo\weights\export.xml
[ SUCCESS ] BIN file: C:\dev\yolo\weights\export.bin
[ SUCCESS ] Total execution time: 10.24 seconds.

When I try to load this model using the provided YOLO sample from here, loading is fine, but when I inspect the net object in debug mode I see that the outputs are Transpose_231, Transpose_237 and Slice_230/Split.1. When I inspect the layers, I see it contains Transpose_231, Transpose_237 and Slice_230/Split (note, missing .1 in the split)

This causes the sample to fail with KeyError: 'Slice_230/Split.1' in

    for layer_name, out_blob in output.items():
        out_blob = out_blob.buffer.reshape(net.layers[net.layers[layer_name].parents[0]].out_data[0].shape)

If I inspect the IR's .XML file I don't see any .1 in it

        <layer id="214" name="Slice_230/Split" type="VariadicSplit" version="opset1">
            <input>
                <port id="0">
                    <dim>6</dim>
                    <dim>142191</dim>
                </port>
                <port id="1"/>
                <port id="2">
                    <dim>3</dim>
                </port>
            </input>
            <output>
                <port id="3" precision="FP32">
                    <dim>4</dim>
                    <dim>142191</dim>
                </port>
                <port id="4" precision="FP32">
                    <dim>1</dim>
                    <dim>142191</dim>
                </port>
                <port id="5" precision="FP32">
                    <dim>1</dim>
                    <dim>142191</dim>
                </port>
            </output>
        </layer>

Any suggestions where this .1 comes from?

EDIT

Tried using opset 9, the same thing happens only this time with Slice_174/Split & Slice_174/Split.1

1

There are 1 answers

0
Rommel_Intel On

The split-1 is actually a Category of Data movement operations. It Split operation splits an input tensor into pieces of the same length along some axis.

This Split operation splits the "data" input tensor into pieces of the same length along "axis". The i-th shape of output tensor will be equal to the "data" shape except along dimension "axis" where the shape will be data.shape[i]/num_splits. The sum of elements of split_lengths must match data.shape[axis].

One of the example:

<layer id="1" type="Split" ...>
    <data num_splits="3" />
    <input>
        <port id="0">       <!-- some data -->
            <dim>6</dim>
            <dim>12</dim>
            <dim>10</dim>
            <dim>24</dim>
        </port>
        <port id="1">       <!-- axis: 1 -->
        </port>
    </input>
    <output>
        <port id="2">
            <dim>6</dim>
            <dim>4</dim>
            <dim>10</dim>
            <dim>24</dim>
        </port>
        <port id="3">
            <dim>6</dim>
            <dim>4</dim>
            <dim>10</dim>
            <dim>24</dim>
        </port>
        <port id="4">
            <dim>6</dim>
            <dim>4</dim>
            <dim>10</dim>
            <dim>24</dim>
        </port>
    </output>
</layer>

You may refer here for further info: https://docs.openvinotoolkit.org/latest/openvino_docs_ops_movement_Split_1.html