Comments (6)
@PINTO0309 super interesting, thanks for the detailed response!
The 3 transpose ops are occurring 1 in each of the output grids P3/8, P4/16, P5/32. The permute op is undesirable as it leaves the output not contiguous, so it requires a .contiguous() method afterward.
I'll revisit the idea of removing the permutation completely from YOLOv5. It's a legacy from YOLOv3 onward, but maybe there's a better way I can restructure this module.
from openvino2tensorflow.
- convert - first try
openvino2tensorflow \
--model_path yolov5n.xml \
--output_saved_model \
--output_pb \
--non_verbose \
--output_no_quant_float32_tflite
- Here.
Shape Error
occurred.
ERROR: axes don't match array
ERROR: model_path : yolov5n.xml
ERROR: weights_path: yolov5n.bin
ERROR: layer_id : 271 <<<<<<<<<<<--------------------- Shape Error occured
ERROR: input_layer0 layer_id=269: KerasTensor(type_spec=TensorSpec(shape=(1, 80, 3, 85, 2), dtype=tf.float32, name=None), name='tf.math.multiply/Mul:0', description="created by layer 'tf.math.multiply'")
ERROR: input_layer1 layer_id=270: Const(ndarray).shape (1, 3, 80, 80, 2)
array([[[[[ -4., -4.],
[ 4., -4.],
[ 12., -4.],
:
:
ERROR: Please refer to 6-7 in the README first. https://github.com/PINTO0309/openvino2tensorflow
- The conversion of the unpredictable transposition operation from
NCDHW
toNCHWD
fails at this point. Mechanically unpredictable transposition operations require the tool's behavior to be modified using JSON files. The cause of this error is that the transpose before the OP in which the error occurs failed to correct the transposition order.
layer_type: Reshape
layer_id: 261
input_layer0: layer_id=259: KerasTensor(type_spec=TensorSpec(shape=(1, 80, 80, 255), dtype=tf.float32, name=None), name='tf.math.add_52/Add:0', description="created by layer 'tf.math.add_52'")
input_layer1_shape: layer_id=260: (5,)
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 80, 80, 3, 85), dtype=tf.float32, name=None), name='tf.reshape/Reshape:0', description="created by layer 'tf.reshape'")
====================================================================================
layer_type: Const
layer_id: 262
tf_layers_dict_shape: (5,)
====================================================================================
layer_type: Transpose
layer_id: 263 <<<<<<<<<<<--------------------- The conversion of the unpredictable transposition operation from NCDHW to NCHWD fails at this point.
input_layer0: layer_id=261: KerasTensor(type_spec=TensorSpec(shape=(1, 80, 80, 3, 85), dtype=tf.float32, name=None), name='tf.reshape/Reshape:0', description="created by layer 'tf.reshape'")
input_layer1_shape: layer_id=262: (5,)
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 80, 3, 85, 80), dtype=tf.float32, name=None), name='tf.compat.v1.transpose/transpose:0', description="created by layer 'tf.compat.v1.transpose'")
- replace_n.json - first step
Rewrite the transposition order ofTranspose
so that it behaves as expected. The inverted order constant corresponds to the layer number of the name of output minus 1.output name: 263:2
-> layer_id:262 =custom name: Constant_3067
{
"format_version": 2,
"layers": [
{
"layer_id": "262",
"type": "Const",
"replace_mode": "direct",
"values": [
0,
3,
1,
2,
4
]
}
]
}
- re-convert
openvino2tensorflow \
--model_path yolov5n.xml \
--output_saved_model \
--output_pb \
--non_verbose \
--output_no_quant_float32_tflite \
--weight_replacement_config replace_n.json
Shape Error
occurred.
ERROR: axes don't match array
ERROR: model_path : yolov5n.xml
ERROR: weights_path: yolov5n.bin
ERROR: layer_id : 328 <<<<<<<<<<<--------------------- Shape Error occured
ERROR: input_layer0 layer_id=326: KerasTensor(type_spec=TensorSpec(shape=(1, 40, 3, 85, 2), dtype=tf.float32, name=None), name='tf.math.multiply_3/Mul:0', description="created by layer 'tf.math.multiply_3'")
ERROR: input_layer1 layer_id=327: Const(ndarray).shape (1, 3, 40, 40, 2)
array([[[[[ -8., -8.],
[ 8., -8.],
[ 24., -8.],
- The conversion of the unpredictable transposition operation from
NCDHW
toNCHWD
fails at this point.
====================================================================================
layer_type: Reshape
layer_id: 318
input_layer0: layer_id=316: KerasTensor(type_spec=TensorSpec(shape=(1, 40, 40, 255), dtype=tf.float32, name=None), name='tf.math.add_60/Add:0', description="created by layer 'tf.math.add_60'")
input_layer1_shape: layer_id=317: (5,)
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 40, 40, 3, 85), dtype=tf.float32, name=None), name='tf.reshape_2/Reshape:0', description="created by layer 'tf.reshape_2'")
====================================================================================
layer_type: Const
layer_id: 319
tf_layers_dict_shape: (5,)
====================================================================================
layer_type: Transpose
layer_id: 320 <<<<<<<<<<<--------------------- The conversion of the unpredictable transposition operation from NCDHW to NCHWD fails at this point.
input_layer0: layer_id=318: KerasTensor(type_spec=TensorSpec(shape=(1, 40, 40, 3, 85), dtype=tf.float32, name=None), name='tf.reshape_2/Reshape:0', description="created by layer 'tf.reshape_2'")
input_layer1_shape: layer_id=319: (5,)
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 40, 3, 85, 40), dtype=tf.float32, name=None), name='tf.compat.v1.transpose_1/transpose:0', description="created by layer 'tf.compat.v1.transpose_1'")
====================================================================================
- replace_n.json - second step
{
"format_version": 2,
"layers": [
{
"layer_id": "262",
"type": "Const",
"replace_mode": "direct",
"values": [
0,
3,
1,
2,
4
]
},
{
"layer_id": "319",
"type": "Const",
"replace_mode": "direct",
"values": [
0,
3,
1,
2,
4
]
}
]
}
- re-convert
openvino2tensorflow \
--model_path yolov5n.xml \
--output_saved_model \
--output_pb \
--non_verbose \
--output_no_quant_float32_tflite \
--weight_replacement_config replace_n.json
Shape Error
occurred.
ERROR: axes don't match array
ERROR: model_path : yolov5n.xml
ERROR: weights_path: yolov5n.bin
ERROR: layer_id : 384
ERROR: input_layer0 layer_id=382: KerasTensor(type_spec=TensorSpec(shape=(1, 20, 3, 85, 2), dtype=tf.float32, name=None), name='tf.math.multiply_6/Mul:0', description="created by layer 'tf.math.multiply_6'")
ERROR: input_layer1 layer_id=383: Const(ndarray).shape (1, 3, 20, 20, 2)
array([[[[[-16., -16.],
[ 16., -16.],
- The conversion of the unpredictable transposition operation from
NCDHW
toNCHWD
fails at this point.
====================================================================================
layer_type: Reshape
layer_id: 374
input_layer0: layer_id=372: KerasTensor(type_spec=TensorSpec(shape=(1, 20, 20, 255), dtype=tf.float32, name=None), name='tf.math.add_68/Add:0', description="created by layer 'tf.math.add_68'")
input_layer1_shape: layer_id=373: (5,)
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 20, 20, 3, 85), dtype=tf.float32, name=None), name='tf.reshape_4/Reshape:0', description="created by layer 'tf.reshape_4'")
====================================================================================
layer_type: Const
layer_id: 375
tf_layers_dict_shape: (5,)
====================================================================================
layer_type: Transpose
layer_id: 376 <<<<<<<<<<<--------------------- The conversion of the unpredictable transposition operation from NCDHW to NCHWD fails at this point.
input_layer0: layer_id=374: KerasTensor(type_spec=TensorSpec(shape=(1, 20, 20, 3, 85), dtype=tf.float32, name=None), name='tf.reshape_4/Reshape:0', description="created by layer 'tf.reshape_4'")
input_layer1_shape: layer_id=375: (5,)
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 20, 3, 85, 20), dtype=tf.float32, name=None), name='tf.compat.v1.transpose_2/transpose:0', description="created by layer 'tf.compat.v1.transpose_2'")
====================================================================================
12. replace_n.json - second step
{
"format_version": 2,
"layers": [
{
"layer_id": "262",
"type": "Const",
"replace_mode": "direct",
"values": [
0,
3,
1,
2,
4
]
},
{
"layer_id": "319",
"type": "Const",
"replace_mode": "direct",
"values": [
0,
3,
1,
2,
4
]
},
{
"layer_id": "375",
"type": "Const",
"replace_mode": "direct",
"values": [
0,
3,
1,
2,
4
]
}
]
}
- re-convert
openvino2tensorflow \
--model_path yolov5n.xml \
--output_saved_model \
--output_pb \
--non_verbose \
--output_no_quant_float32_tflite \
--weight_replacement_config replace_n.json
- success
====================================================================================
layer_type: Result
layer_id: 394
input_layer0: layer_id=393: KerasTensor(type_spec=TensorSpec(shape=(1, 25200, 85), dtype=tf.float32, name=None), name='tf.concat_16/concat:0', description="created by layer 'tf.concat_16'")
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 25200, 85), dtype=tf.float32, name=None), name='tf.identity/Identity:0', description="created by layer 'tf.identity'")
====================================================================================
TensorFlow/Keras model building process complete!
saved_model output started ==========================================================
WARNING:absl:Found untraced functions such as _jit_compiled_convolution_op, _jit_compiled_convolution_op, _jit_compiled_convolution_op, _jit_compiled_convolution_op, _jit_compiled_convolution_op while saving (showing 5 of 60). These functions will not be directly callable after loading.
saved_model output complete!
.pb output started ==================================================================
.pb output complete! - saved_model/model_float32.pb
tflite Float32 convertion started ===================================================
WARNING:absl:Found untraced functions such as _jit_compiled_convolution_op, _jit_compiled_convolution_op, _jit_compiled_convolution_op, _jit_compiled_convolution_op, _jit_compiled_convolution_op while saving (showing 5 of 60). These functions will not be directly callable after loading.
Estimated count of arithmetic ops: 5.393 G ops, equivalently 2.697 G MACs
tflite Float32 convertion complete! - saved_model/model_float32.tflite
All the conversion process is finished! =============================================
from openvino2tensorflow.
All issues of YOLOv5 asked the same question.
#115
#102
#99
#91
#88
#86
#82
#77
#54
#50
#48
#41
#38
#33
#21
from openvino2tensorflow.
Btw, If you want to rename an input/output layer, you can easily rewrite it manually using this tool.
https://github.com/PINTO0309/tflite2json2tflite
from openvino2tensorflow.
Closed due to no activity for over a week.
from openvino2tensorflow.
https://github.com/PINTO0309/onnx2tf
from openvino2tensorflow.
Related Issues (20)
- While converting openvino (xml) to Tensorflow saved_output_model, getting following error.temp_sorted_tf_edge.append(tf_edges[to_layer][ports.index(str(idx))]) IndexError: list index out of range
- error in converting openvino to tflite HOT 5
- C3D model conversion - Depth of input (112) is not a multiple of input depth of filter (3) for '{{node tf.nn.conv3d/Conv3D}} HOT 2
- Refactoring for use as importable package HOT 3
- ScatterUpdate node issue HOT 1
- whisper openvino to tflite(https://huggingface.co/zhuzilin/whisper-openvino-tiny.en/tree/main) HOT 1
- bug in layer graph construction HOT 1
- KeyError in channel split HOT 3
- Converting a Yolov5 model to tensorflow HOT 1
- conversion of Yolov7-tiny ends with ERROR: axes don't match array HOT 2
- IndexError: list index out of range HOT 2
- Size discrepancy in conversion HOT 1
- "091_gaze-estimation-adas-0002" failed HOT 2
- Layer data type changes during conversion HOT 1
- Unable to convert yolov8 openvino model to tensorflow HOT 1
- Ranks of all input tensors should match: shape[0] = [1,1] vs. shape[1] = [1] [Op:ConcatV2] name: concat HOT 1
- Error of saving json during converting openvino model to tensorflow with parameter --output_weight_and_json HOT 1
- TypeError: cannot pickle 'module' object HOT 1
- Shape did not match HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openvino2tensorflow.