PINTO0309 / openvino2tensorflow

This script converts the ONNX/OpenVINO IR model to Tensorflow's saved_model, tflite, h5, tfjs, tftrt(TensorRT), CoreML, EdgeTPU, ONNX and pb. PyTorch (NCHW) -> ONNX (NCHW) -> OpenVINO (NCHW) -> openvino2tensorflow -> Tensorflow/Keras (NHWC/NCHW) -> TFLite (NHWC/NCHW). And the conversion from .pb to saved_model and from saved_model to .pb and from .pb to .tflite and saved_model to .tflite and saved_model to onnx. Support for building environments with Docker. It is possible to directly access the host PC GUI and the camera to verify the operation. NVIDIA GPU (dGPU) support. Intel iHD GPU (iGPU) support.
MIT License
334 stars 40 forks source link

Conversion error: Shape must be rank 1 but is rank 2 #90

Closed larrywal-express closed 2 years ago

larrywal-express commented 2 years ago

model.zip

@PINTO0309 Thanks for your good work. I obtained the error below in trying to convert from .xml to saved_model, pb, tflite. Also tried to used replace.json for layer_id 325, but all effort was fruitless. How do i solve this problem? The model.zip attached. Thanks.

ERROR: Exception encountered when calling layer "tf.reshape_6" (type TFOpLambda).

Shape must be rank 1 but is rank 2 for '{{node tf.reshape_6/Reshape}} = Reshape[T=DT_FLOAT, Tshape=DT_INT64](Placeholder, tf.reshape_6/Reshape/shape)' with input shapes: [1,1,1,256], [2,1].

Call arguments received: • tensor=tf.Tensor(shape=(1, 1, 1, 256), dtype=float32) • shape=['tf.Tensor(shape=(1,), dtype=int64)', 'tf.Tensor(shape=(1,), dtype=int64)'] • name=None ERROR: model_path : lite_openvino_model/lite.xml ERROR: weights_path: lite_openvino_model/lite.bin ERROR: layer_id : 326 ERROR: input_layer0 layer_id=312: KerasTensor(type_spec=TensorSpec(shape=(1, 1, 1, 256), dtype=tf.float32, name=None), name='tf.math.reduce_mean/Mean:0', description="created by layer 'tf.math.reduce_mean'") ERROR: input_layer1 layer_id=325: tf.Tensor( [[ 1] [16]], shape=(2, 1), dtype=int64) ERROR: The trace log is below. Traceback (most recent call last): File "openvino2tensorflow.py", line 3758, in convert tf_layers_dict[layer_id] = tf.reshape(op1, shape) File "D:\Anaconda3\lib\site-packages\tensorflow\python\util\traceback_utils.py", line 153, in error_handler raise e.with_traceback(filtered_tb) from None File "D:\Anaconda3\lib\site-packages\keras\layers\core\tf_op_layer.py", line 107, in handle return TFOpLambda(op)(*args, **kwargs) File "D:\Anaconda3\lib\site-packages\keras\utils\traceback_utils.py", line 67, in error_handler raise e.with_traceback(filtered_tb) from None ValueError: Exception encountered when calling layer "tf.reshape_6" (type TFOpLambda).

Shape must be rank 1 but is rank 2 for '{{node tf.reshape_6/Reshape}} = Reshape[T=DT_FLOAT, Tshape=DT_INT64](Placeholder, tf.reshape_6/Reshape/shape)' with input shapes: [1,1,1,256], [2,1].

Call arguments received: • tensor=tf.Tensor(shape=(1, 1, 1, 256), dtype=float32) • shape=['tf.Tensor(shape=(1,), dtype=int64)', 'tf.Tensor(shape=(1,), dtype=int64)'] • name=None

PINTO0309 commented 2 years ago

I'm sorry to bother you. Can you post it again using the issue template? :smile: image