MPolaris / onnx2tflite

Tool for onnx->keras or onnx->tflite. If tool is useful for you, please star it.
Apache License 2.0
487 stars 33 forks source link

weight value errot #65

Open weiiiifun opened 1 week ago

weiiiifun commented 1 week ago

(tf_env) lab@lab-Z690-UD-DDR4-V2:~/Desktop/workspace/onnx2tflite-main$ python converter.py --weights "./video.onnx" --formats "tflite" --int8 2024-06-26 15:54:29.347156: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable TF_ENABLE_ONEDNN_OPTS=0. 2024-06-26 15:54:29.348163: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used. 2024-06-26 15:54:29.366870: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used. 2024-06-26 15:54:29.367155: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. 2024-06-26 15:54:29.641267: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT Checking 0/1... 2024-06-26 15:54:34.334577: E tensorflow/compiler/xla/stream_executor/cuda/cuda_driver.cc:268] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected INFO:deformation_layers ::Transpose will process tensor after change back to NCHW format. Traceback (most recent call last): File "converter.py", line 108, in run() File "converter.py", line 92, in run onnx_converter( File "converter.py", line 21, in onnx_converter keras_model = keras_builder(model_proto, native_groupconv) File "/home/lab/Desktop/workspace/onnx2tflite-main/utils/builder.py", line 81, in keras_builder res = tf_operator(tf_tensor, onnx_weights, node_inputs, op_attr, outputs=node_outputs)(_inputs) File "/home/lab/Desktop/workspace/onnx2tflite-main/layers/conv_layers.py", line 87, in call return self.conv(inputs) File "/home/lab/Desktop/workspace/onnx2tflite-main/layers/conv_layers.py", line 155, in call return self.conv(inputs) File "/home/lab/anaconda3/envs/tf_env/lib/python3.8/site-packages/keras/src/utils/traceback_utils.py", line 70, in error_handler raise e.with_traceback(filtered_tb) from None File "/home/lab/anaconda3/envs/tf_env/lib/python3.8/site-packages/keras/src/engine/base_layer.py", line 1832, in set_weights raise ValueError( ValueError: Layer conv2d weight shape (16, 16, 8, 768) is not compatible with provided weight shape (16, 16, 3, 768).

截屏2024-06-26 16 24 49

请问这个要怎么解决?

MPolaris commented 1 week ago

你这个ONNX模型似乎不是从pytorch导出来的吧,目前onnx2tflite仅考虑了pytorch导出的模型,也就是channel-first的模型。