}
}
-static DNNReturnType init_model_ov(OVModel *ov_model)
+static DNNReturnType init_model_ov(OVModel *ov_model, const char *input_name, const char *output_name)
{
OVContext *ctx = &ov_model->ctx;
IEStatusCode status;
goto err;
}
+ // The order of dims in the openvino is fixed and it is always NCHW for 4-D data.
+ // while we pass NHWC data from FFmpeg to openvino
+ status = ie_network_set_input_layout(ov_model->network, input_name, NHWC);
+ if (status != OK) {
+ av_log(ctx, AV_LOG_ERROR, "Failed to set layout as NHWC for input %s\n", input_name);
+ goto err;
+ }
+ status = ie_network_set_output_layout(ov_model->network, output_name, NHWC);
+ if (status != OK) {
+ av_log(ctx, AV_LOG_ERROR, "Failed to set layout as NHWC for output %s\n", output_name);
+ goto err;
+ }
+
status = ie_core_load_network(ov_model->core, ov_model->network, ctx->options.device_type, &config, &ov_model->exe_network);
if (status != OK) {
av_log(ctx, AV_LOG_ERROR, "Failed to load OpenVINO model network\n");
}
if (!ov_model->exe_network) {
- if (init_model_ov(ov_model) != DNN_SUCCESS) {
+ if (init_model_ov(ov_model, input_name, output_name) != DNN_SUCCESS) {
av_log(ctx, AV_LOG_ERROR, "Failed init OpenVINO exectuable network or inference request\n");
return DNN_ERROR;
}
}
if (!ov_model->exe_network) {
- if (init_model_ov(ov_model) != DNN_SUCCESS) {
+ if (init_model_ov(ov_model, input_name, output_names[0]) != DNN_SUCCESS) {
av_log(ctx, AV_LOG_ERROR, "Failed init OpenVINO exectuable network or inference request\n");
return DNN_ERROR;
}
}
if (!ov_model->exe_network) {
- if (init_model_ov(ov_model) != DNN_SUCCESS) {
+ if (init_model_ov(ov_model, input_name, output_names[0]) != DNN_SUCCESS) {
av_log(ctx, AV_LOG_ERROR, "Failed init OpenVINO exectuable network or inference request\n");
return DNN_ERROR;
}