openvino: Error in `mo` API

So I am converting TensorFlow model in SavedModel format to openvino-IR when I use API method

from openvino.tools import mo
model_ir = mo.convert_model(saved_model_dir=str(MODEL_DIR_PATH),data_type='FP32')

I got error

Error: Exception occurred during running replacer "REPLACEMENT_ID" (<class 'openvino.tools.mo.load.tf.loader.TFLoader'>): Unexpected exception happened during extracting attributes for node StatefulPartitionedCall/StatefulPartitionedCall/Postprocessor/BatchMultiClassNonMaxSuppression/Slice_3/begin.
Original exception message: index -1 is out of bounds for axis 0 with size 0

but when I use command-line !mo --saved_model_dir SavedModel --data_type FP32 --output_dir IR it successfully generates XML and bin file but I have to use API only can anyone help me out !!

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 24 (8 by maintainers)

Most upvoted comments

Hi @ashish-2005,

I would like to ask you to check two points:

  1. please check that OpenVINO runtime version and MO version match and are the same in both cases. For this, you need to add option --silent False as follows:
model_ir = mo.convert_model(saved_model_dir=str(MODEL_DIR_PATH),data_type='FP32', silent=False)

and

mo --saved_model_dir yolo_v4/ --silent False

After that, you can collect these versions for both cases. They look like as follows:

OpenVINO runtime version:       xxxx-xxxx
Model Optimizer version:        xxxx-xxxx

Please share these versions.

  1. Please check that you use the same environment in both cases. Namely, check version of TensorFlow like:
import tensorflow as tf
tf.__version__

Best regards, Roman

Hi @rkazants,

Is there an update on this? I have a project deadline approaching. If we don’t have anything yet, is there any sort of workaround for the moment? Maybe an older version of openvino which doesn’t have this issue and is compatible with 2.11 version of tensorflow?

Hi @CrackedDS,

I reproduced this issue using both CLI tool and MO API. I sin to freezing functionality (to get frozen .pb) for some concrete versions of TF. Some constant node created by freezing turns to be empty. Let me deep dive into why it happens.

Best regards, Roman

Hi @rkazants

Mine has started working somehow, the only change I made is that I didn’t run the mo command-line cell (which I was doing before) and now API is doing fine

As for the model, I am using a pre-trained model efficientdet-d0 from TensorFlow-Hub I first loaded the model with tensorflow_hub API, then saved it in SavedModel format with tf.saved_model.save() and then used the MO API to create Intermediate-Representation

Thanks again for your time Ashish