Face-Detector-1MB-with-landmark
Face-Detector-1MB-with-landmark copied to clipboard
onnx转换ncnn模型错误
非常感谢您的工作, 我按照您的说明产生了onnx文件,接着转换ncnn的时候有如下报错: ./onnx2ncnn faceDetector.onnx m25.param m25.bin ./onnx2ncnn: symbol lookup error: ./onnx2ncnn: undefined symbol: _ZN6google8protobuf2io17CodedOutputStream21WriteVarint32SlowPathEj
当我使用自己编译好的ncnn时,又出现了一些不支持的问题: ncnn/build/tools/onnx/onnx2ncnn faceD etector.onnx m25.param m25.bin Shape not supported yet! Gather not supported yet!
axis=0
Shape not supported yet! Gather not supported yet!
axis=0
Unsqueeze not supported yet!
axes 7
Unsqueeze not supported yet!
axes 7
Cast not supported yet!
to=1
Shape not supported yet! Cast not supported yet!
to=1
Segmentation fault (core dumped)
请教您是怎么解决这个问题的,不胜感激!
pytorch生成onnx转换模型时有一些冗余,我们用工具简化一下onnx模型 执行下面命令 pip install onnx-simplifier python -m onnxsim face.onnx face_sim.onnx 转换就是正常的了
简化过程报错误了,没找到相关的解决
python3 -m onnxsim faceDetector.onnx faceDetector_sim.onnx
Simplifying...
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/rongy/.local/lib/python3.5/site-packages/onnxsim/main.py", line 24, in
Sorry, 转换没遇到类似问题, 操作流程完全是和ncnn给出的教程一致(https://github.com/Tencent/ncnn/wiki/use-ncnn-with-pytorch-or-onnx)你可以在NCNN项目下查找相关解决方案.
简化过程报错误了,没找到相关的解决
我是 onnx-simplifier 的作者,最近在出差,回去之后找时间看一下这个问题
简化过程报错误了,没找到相关的解决
我是 onnx-simplifier 的作者,最近在出差,回去之后找时间看一下这个问题
大佬太强了!
简化过程报错误了,没找到相关的解决
我是 onnx-simplifier 的作者,最近在出差,回去之后找时间看一下这个问题
太强了@_@
我也遇到了这个问题,@Royzon 去onnx optimizer搜了下,可以看下这个issue https://github.com/onnx/onnx/issues/1385,貌似是因为模型训练使用GPU设备 ,但是在转换时未使用GPU导致的, 我本地换版本比较麻烦,你可以试试。
@biubug6 您好,这个模型默认是GPU device吧?
简化过程报错误了,没找到相关的解决
我是 onnx-simplifier 的作者,最近在出差,回去之后找时间看一下这个问题
给大佬倒橙汁
@zjd1988 转换默认使用的是加载CPU上, 刚刚重新尝试了一下,转换正常......
@biubug6 你好,你用的onnx和onnx-sim的版本是多少呢?我本地换了很多版本都不行(▼皿▼#)
@zjd1988 onnx-sim 0.1.8 pytorch 1.2 python3.7
@biubug6 谢谢啦,我明天按你的版本配置试一下。
@Royzon 早上使用和@biubug6 一样的版本,能够将模型正常转换了,你可以试试。
我搞定啦
you have to add keep_initializers_as_inputs=True when exporting onnx
torch.onnx._export(model, x, "model.onnx", export_params=True, keep_initializers_as_inputs=True)
since this commit
https://github.com/pytorch/pytorch/commit/7583519b870e33ee3182f330c1bb8663559697b6
我搞定啦
you have to add keep_initializers_as_inputs=True when exporting onnx
torch.onnx._export(model, x, "model.onnx", export_params=True, keep_initializers_as_inputs=True)
since this commit
膜拜nihui大佬!
@nihui @daquexian @zjd1988 @monkeyking @biubug6 多谢各位鼎力相助,thanks。
各位大佬!我使用了和zjd1988 一样的版本,在进行onnx_sim的时候,发现简化的onnx模型还存在upsample导致ncnn无法识别,这个该怎样解决呀?
遇见同样的问题,不好解决
导出ONNX的时候,torch.onnx._export(model, x, "model.onnx", export_params=True, keep_initializers_as_inputs=True, opset_version=11),一定要加上opset_version=11。这样转化的时候基本不会报错