MPolaris / onnx2tflite

Tool for onnx->keras or onnx->tflite. Hope this tool can help you.
Apache License 2.0
519 stars 41 forks source link

An Arcface model cannot be converted #35

Closed PaulX1029 closed 1 year ago

PaulX1029 commented 1 year ago

模型优化失败, 从./models/arcface.onnx加载 2023-03-04 14:26:09.484399: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /mnt/sda/AI/miniconda3/envs/yolov5/lib/python3.7/site-packages/cv2/../../lib64: 2023-03-04 14:26:09.484419: W tensorflow/stream_executor/cuda/cuda_driver.cc:263] failed call to cuInit: UNKNOWN ERROR (303) 2023-03-04 14:26:09.484429: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (ubuntu): /proc/driver/nvidia/version does not exist 2023-03-04 14:26:09.484577: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. Traceback (most recent call last): File "/mnt/sda/AI/onnx2tflite-main/converter.py", line 70, in run() File "/mnt/sda/AI/onnx2tflite-main/converter.py", line 66, in run image_root=opt.imgroot File "/mnt/sda/AI/onnx2tflite-main/converter.py", line 18, in onnx_converter keras_model = keras_builder(model_proto, input_node_names, output_node_names) File "/mnt/sda/AI/onnx2tflite-main/utils/builder.py", line 88, in keras_builder tf_tensor[node_outputs[index]] = tf_operator(tf_tensor, onnx_weights, node_inputs, op_attr, index=index)(_inputs) File "/mnt/sda/AI/onnx2tflite-main/layers/activations_layers.py", line 65, in init self.slope = node_weights[node_inputs[1]].transpose(1, 2, 0) ValueError: axes don't match array

进程已结束,退出代码1

PaulX1029 commented 1 year ago

image

MPolaris commented 1 year ago

It's seem a new pattern of PRelu. Your onnx model version is 16, can you provide model file to me or fix it by yourself.

PaulX1029 commented 1 year ago

It's seem a new pattern of PRelu. Your onnx model version is 16, can you provide model file to me or fix it by yourself.

我可以将onnx模型提供给您,我也可以先将onnx版本降低到多少再试试呢?

PaulX1029 commented 1 year ago

链接: https://pan.baidu.com/s/1ksZcbMwm5v8N5JqVGgmdvQ?pwd=t7jw 提取码: t7jw --来自百度网盘超级会员v3的分享

PaulX1029 commented 1 year ago

链接: https://pan.baidu.com/s/1ksZcbMwm5v8N5JqVGgmdvQ?pwd=t7jw 提取码: t7jw --来自百度网盘超级会员v3的分享

onnx模型链接地址在这里,我先从mxnet转换为onnx的,转换脚本如下:

import mxnet as mx
import numpy as np
import onnx

print('mxnet version:', mx.__version__)
print('onnx version:', onnx.__version__)
from mxnet.contrib import onnx as onnx_mxnet
from onnx import checker
syms = './mxnet_models/arcface/model-symbol.json'
params = './mxnet_models/arcface/model-0000.params'
input_shape = (1, 3, 112, 112)
onnx_file = './models/arcface_onnx131.onnx'

converted_model_path = onnx_mxnet.export_model(syms, params, [input_shape], np.float32, onnx_file)

model_proto = onnx.load_model(converted_model_path)

checker.check_graph(model_proto.graph)
MPolaris commented 1 year ago

It's fixed, please pull latest code.

PaulX1029 commented 1 year ago

@MPolaris Thank you!