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

Layout conversion

aag
Novice
413 Views

Does OpenVino provide means to convert input layout internally, or does input always need to be provided in the layout required by the model?

0 Kudos
5 Replies
SuryaPSC_Intel
Employee
413 Views

Hi Alex,

If the network assumes the RGB inputs, the Model Optimizer can swap the channels in the first convolution using the --reverse_input_channels command line option, so we do not need to convert the inputs to RGB every time we get the BGR image, for example, from OpenCV

Best Regards,

Surya

aag
Novice
413 Views

Thanks, but this is not exactly what I'm looking for. The image comes interleaved (e.g. NHWC) from the decoder, but the network requires planar (e.g. NCHW). Does OpenVino have a conversion API (explicit or implicit), or does the conversion need to happen externally.

SuryaPSC_Intel
Employee
413 Views

Hi Alex,

By default, Inference Engine accepts the planar and not interleaved inputs in NCHW, so the NHWC (which is exactly the interleaved layout) should be specified explicitly.

The InferenceEngine::NHWC layout is not supported natively by most InferenceEngine plugins, so internal conversion might happen.

Kindly refer to OpenCV* Interoperability Example

 

Best Regards,

Surya

aag
Novice
413 Views

But that's just the point -- internal conversions do not seem to be happening. 

Providing NHWC blob to a network expecting NCHW input results in

`[PARAMETER_MISMATCH] Failed to set input Blob. Dimensions mismatch.`

exception being thrown. OpenCV samples you refer to, seem to use both approaches (matU8ToBlob performs external NHWC->NCHW conversion; wrapMat2Blob wraps a NHWC blob and passes it to input). However, the latter never seems to work for me.

SuryaPSC_Intel
Employee
413 Views

HI Alex,

You may try doing the conversion within the decoder itself before feeding it into the inference engine.

You can also refer to the object_detection_demo_ssd_async.py to modify the layout.

Best Regards,

Surya

Reply