Open arnoldfychen opened 2 years ago
P.S., I can provide you the model onnx for reproducing this issue to help the progress of resolving it
if your train framework is Pytorch, please use PNNX to convert your model to ncnn
if your train framework is Pytorch, please use PNNX to convert your model to ncnn
Thank you, but it looks like pnnx is not formally included in the tools CMake project yet ?
Thank you, but it looks like pnnx is not formally included in the tools CMake project yet ?
You are wrong, PNNX is the most important tool to convert model from Pytorch.
I mean the pnnx tool under ncnn/tools, after having built ncnn, pnnx is not found under tools, and checked the CMakeLists.txt under tools, pnnx directory is not included.
I mean the pnnx tool under ncnn/tools, after having built ncnn, pnnx is not found under tools, and checked the CMakeLists.txt under tools, pnnx directory is not included.
Yes you are right, but it's really the most important tool to convert model from Pytorch to ncnn.
Why CMakeLists.txt does not include pnnx? is pnnx still not a stable?
Why CMakeLists.txt does not include pnnx? is pnnx still not a stable?
非常的stable啊,你們哪裏感覺它不stable的? 不加進去估計是因爲編譯需要依賴libtorch,那個東西有點大
NCNN 的 CMakeLists 很強大阿,支援各種compile flag。 倘若source code 已經放在ncnn/tools 底下,但CMakeLists 沒放進去,想必有其原因吧? 看來真如您所說,需要 libtorch,這並不是所有人都需要且超過此project的範疇了!
For yolov5-v6.1
# convert .pt to .onnx
python3 export.py --weights path/to/your/*.pt --include onnx --train
# convert .onnx to *-sim.onnx
pip3 install onnx-simplifier
python3 -m onnxsim path/to/your/*.onnx path/to/your/*-sim.onnx
# out-of-the-box web model conversion
https://convertmodel.com/#outputFormat=ncnn
One can use onnx2ncnn or pnnx to convert yolov5 pytorch model without Detect() layer to ncnn, that is export with --train option.
If use pnnx, you have no need to compile it: https://github.com/pnnx/pnnx/releases
But I think it's better to export with Detect() layer, so you don't have to deal with anchors (anchors may change with models), hope this can be supported in the future.
针对onnx模型转换的各种问题,推荐使用最新的pnnx工具转换到ncnn In view of various problems in onnx model conversion, it is recommended to use the latest pnnx tool to convert your model to ncnn
pip install pnnx
pnnx model.onnx inputshape=[1,3,224,224]
详细参考文档 Detailed reference documentation https://github.com/pnnx/pnnx https://github.com/Tencent/ncnn/wiki/use-ncnn-with-pytorch-or-onnx#how-to-use-pnnx
使用了pnnx转换 @nihui 但是nccn中的shape与pnnx对于不上;输入shape为[1,368,64]
error log | 日志或报错信息 | ログ
Shape not supported yet! Gather not supported yet!
axis=0
Shape not supported yet! Gather not supported yet!
axis=0
Shape not supported yet! Gather not supported yet!
axis=0
Unknown data type 0 Unsupported slice axes ! Unsupported slice axes ! Unsupported slice axes ! Unknown data type 0 Shape not supported yet! Gather not supported yet!
axis=0
Shape not supported yet! Gather not supported yet!
axis=0
Shape not supported yet! Gather not supported yet!
axis=0
Unknown data type 0 Unsupported slice axes ! Unsupported slice axes ! Unsupported slice axes ! Unknown data type 0 Shape not supported yet! Gather not supported yet!
axis=0
Shape not supported yet! Gather not supported yet!
axis=0
Shape not supported yet! Gather not supported yet!
axis=0
Unknown data type 0 Unsupported slice axes ! Unsupported slice axes ! Unsupported slice axes ! Unknown data type 0
context | 编译/运行环境 | バックグラウンド
how to reproduce | 复现步骤 | 再現方法
more | 其他 | その他
The above error or caution messages also can be seen if you parse the onnx to nccn target on https://convertmodel.com