zheshipinyinmc / arcface_retinaface_mxnet2onnx Goto Github PK
View Code? Open in Web Editor NEWarcface and retinaface model convert mxnet to onnx.
arcface and retinaface model convert mxnet to onnx.
Got an error when I try mxnet2onnx
Traceback (most recent call last):
File "mxnet2onnx_demo.py", line 73, in
mxnet2onnx_test() #==mxnet2onnx
File "mxnet2onnx_demo.py", line 25, in mxnet2onnx_test
converted_model_path = onnx_mxnet.export_model(sym, params, input_shape, np.float32, onnx_file)
File "/hhdxx2/wzq/venv/lib/python3.6/site-packages/mxnet/contrib/onnx/init.py", line 53, in export_model
return export_model_(*args, **kwargs)
File "/hhdxx2/wzq/venv/lib/python3.6/site-packages/mxnet/onnx/mx2onnx/_export_model.py", line 125, in export_model
dynamic=dynamic, dynamic_input_shapes=dynamic_input_shapes)
File "/hhdxx2/wzq/venv/lib/python3.6/site-packages/mxnet/onnx/mx2onnx/_export_onnx.py", line 298, in create_onnx_graph_proto
in_types, dynamic, dynamic_input_shapes)
File "/hhdxx2/wzq/venv/lib/python3.6/site-packages/mxnet/onnx/mx2onnx/_export_onnx.py", line 190, in get_outputs
_, out_shapes, _ = sym.infer_shape(**inputs)
File "/hhdxx2/wzq/venv/lib/python3.6/site-packages/mxnet/symbol/symbol.py", line 1101, in infer_shape
res = self._infer_shape_impl(False, *args, **kwargs)
File "/hhdxx2/wzq/venv/lib/python3.6/site-packages/mxnet/symbol/symbol.py", line 1265, in _infer_shape_impl
ctypes.byref(complete)))
File "/hhdxx2/wzq/venv/lib/python3.6/site-packages/mxnet/base.py", line 246, in check_call
raise get_last_ffi_error()
mxnet.base.MXNetError: MXNetError: Error in operator pre_fc1: Shape inconsistent, Provided = [512,25088], inferred shape=(512,819200)
Code:
def mxnet2onnx_test():
sym = './model/model-symbol.json'
params = './model/model-0000.params'
input_shape = [(1,3,640,640)]
onnx_file = './model/model-0000.onnx'
converted_model_path = onnx_mxnet.export_model(sym, params, input_shape, np.float32, onnx_file)
#Check the model
onnx.checker.check_model(onnx_file)
print('The model is checked!')
if name == 'main':
mxnet2onnx_test() #==mxnet2onnx
Can anyone help me with this issue?
Hi! Great work converting RetinaFace mnet25 model!
I am trying to convert models from official InsightFace python package model zoo (retinaface_mnet025_v1, retinaface_mnet025_v2) using your code. Conversion works fine, but inference output is totally different from MXNet model, making it incompatible with following post processing.
Converted original @yangfly model works as intended.
当使用onnx进行推断时,固定输入模型为(1、3、640、640),但是当使用mxnet进行推断时,输入是任意的,但不是固定的。 我想问的是,在使用onnx模型时,每个输入的大小应调整为(640,640)结果是否与mxnet不同,因为mxnet的输入形状取决于scale参数并且输入形状发生变化每个不同尺寸的输入图像?
感谢您的分享,太好了!
Hi I tried to convert your mxnet retinaface model into onnx but encoutered this error, how can i reform the libraries to handle the error,
AttributeError: No conversion function registered for op type null yet.
2.1) 采用Resize实现
mxnet/contrib/onnx/mx2onnx/_op_translations.py
报错
I tried to convert the coordinateReg of insightface as below:
https://github.com/deepinsight/insightface/tree/master/alignment/coordinateReg
I modified all the things you mentioned about retinaface and arcface.
After conversion, the generated model seems to be same as original model, but its result is not similar to original one, and the result never changes when the input image changed.
Do you have any idea for this?
i think the problems are caused by prelu,flatten, or batchnorm.
README中arcface和retinaface的百度云盘链接反过来了。
Non-zero status code returned while running PRelu node. Name:'relu0' Status Message: relu0: right operand cannot broadcast on dim 0 LeftShape: {1,64,112,112}, RightShape: {64}
你好, 我使用我的pytorch转的onnx模型,获取input_map时只获取了数据输入的节点input
{'input0': name: "input0"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 1
}
dim {
dim_value: 3
}
dim {
dim_value: 112
}
dim {
dim_value: 112
}
}
}
}
}
后面所有节点的input都没有,请问你知道是怎么回事吗
output shape 是 (1, 20, 80, 80)请问这有无问题?
自己尝试用mobilefacenet-res2-6-10-2-dim512进行转换,得到下面的错误,求解答,代码跟作者的一样(解注释了后面几行检查和修改的语句):
2023-05-24 17:48:29.121959761 [W:onnxruntime:, graph.cc:84 MergeShapeInfo] Error merging shape info for output. 'fc1' source:{1,512,1,512} target:{1,512}. Falling back to lenient merge
2023-05-24 17:48:29.168708774 [E:onnxruntime:, sequential_executor.cc:339 Execute] Non-zero status code returned while running Gemm node. Name:'' Status Message: GEMM: Dimension mismatch, W: {512,512} K: 1 N:512
Traceback (most recent call last):
File "mxnet_to_onnx.py", line 155, in
onnx_inferred_demo()
File "mxnet_to_onnx.py", line 52, in onnx_inferred_demo
out = ort_session.run([outputs], input_feed={input_name: input_blob})
File "/usr/local/python3/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 188, in run
return self._sess.run(output_names, input_feed, run_options)
onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Non-zero status code returned while running Gemm node. Name:'' Status Message: GEMM: Dimension mismatch, W: {512,512} K: 1 N:512
@zheshipinyinMc 你好,我测试mxnet2onnx_demo,运行直接报错
==> Context: Bad node spec: input: "conv_1_conv2d" input: "conv_1_batchnorm_gamma" input: "conv_1_batchnorm_beta" input: "conv_1_batchnorm_moving_mean" input: "conv_1_batchnorm_moving_var" output: "conv_1_batchnorm" name: "conv_1_batchnorm" op_type: "BatchNormalization" attribute { name: "epsilon" f: 0.001 type: FLOAT } attribute { name: "momentum" f: 0.9 type: FLOAT } attribute { name: "spatial" i: 0 type: INT }
这个是因为版本问题吗?
我的环境:
mxnet-cu101 1.6.0
onnx 1.7.0
onnxruntime 1.3.0
how to solve this problem when I run mxnet2onnx_demo.py in Arcface demo to mxnet2onnx.
Mxnet 1.6.0
onnx 1.7.0
File "D:/Project/Github/Face/Recognition/arcface_retinaface_mxnet2onnx-master/Arcface/mxnet2onnx_demo.py", line 153, in
mxnet2onnx_test() #==mxnet2onnx
File "D:/Project/Github/Face/Recognition/arcface_retinaface_mxnet2onnx-master/Arcface/mxnet2onnx_demo.py", line 25, in mxnet2onnx_test
converted_model_path = onnx_mxnet.export_model(sym, params, input_shape, np.float, onnx_file)
File "C:\Users\CC.conda\envs\face\lib\site-packages\mxnet\contrib\onnx\mx2onnx\export_model.py", line 83, in export_model
verbose=verbose)
File "C:\Users\CC.conda\envs\face\lib\site-packages\mxnet\contrib\onnx\mx2onnx\export_onnx.py", line 312, in create_onnx_graph_proto
checker.check_graph(graph)
File "C:\Users\CC.conda\envs\face\lib\site-packages\onnx\checker.py", line 54, in checker
proto.SerializeToString(), ctx)
onnx.onnx_cpp2py_export.checker.ValidationError
add inference code for coordinates...
我想试一下较大的模型效果,如果有的话,可以麻烦您发我一份~
[email protected]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.