yolov5-seg-ncnn icon indicating copy to clipboard operation
yolov5-seg-ncnn copied to clipboard

Can you share a way convert model pt to ncnn

Open nqthai309 opened this issue 2 years ago • 11 comments

i used to convert pretrained model yolov5s-seg.pt to ncnn by pnnx tool, but its content of param file is not same content of your param file provided

this is command convert model: ./pnnx yolov5s-seg.torchscript inputshape=[1,3,640,640]

nqthai309 avatar Oct 17 '22 09:10 nqthai309

I have same problem, I try onnx to ncnn and torchscript to pnnx to ncnn

xellDart avatar Nov 06 '22 15:11 xellDart

same problem @FeiGeChuanShu 飞哥救急呀,如何将yolov5s-seg.pt(v7.0) 转换为ncnn?

superbayes avatar Jan 17 '23 08:01 superbayes

Refer @FeiGeChuanShu https://github.com/FeiGeChuanShu/yolov5-seg-ncnn/issues/1#issuecomment-1253376316

  1. export the torchscript file by export.py.
  2. use pnnx tool to convert the torchscript to ncnn model.

How to modify the following commands to generate the correct ncnn model files.

$ python export.py --weights yolov5s-seg.pt --include torchscript
$ ./pnnx yolov5s-seg.torchscript inputshape=[1,3,640,640]

Note that, yolov5s-seg.pt is downloaded from yolov5-7.0.

https://github.com/ultralytics/yolov5/releases/download/v7.0/yolov5s-seg.pt

Digital2Slave avatar Jan 19 '23 06:01 Digital2Slave

Refer @FeiGeChuanShu #1 (comment)

  1. export the torchscript file by export.py.
  2. use pnnx tool to convert the torchscript to ncnn model.

How to modify the following commands to generate the correct ncnn model files.

$ python export.py --weights yolov5s-seg.pt --include torchscript
$ ./pnnx yolov5s-seg.torchscript inputshape=[1,3,640,640]

Note that, yolov5s-seg.pt is downloaded from yolov5-7.0.

https://github.com/ultralytics/yolov5/releases/download/v7.0/yolov5s-seg.pt

output and input of converted model seem different with pre-converted model provided by FeiGeChuanShu.

nqthai309 avatar Jan 19 '23 06:01 nqthai309

@nqthai309 yes. i have the same issue. So i write "How to modify the following commands to generate the correct ncnn model files." No response from @FeiGeChuanShu. Maybe there is something he modified but do not want to show out, just post export.py and pnnx .

Digital2Slave avatar Jan 19 '23 07:01 Digital2Slave

@nqthai309 @superbayes @xellDart It seems block issues of pnnx . I have put an issue https://github.com/Tencent/ncnn/issues/4488

image

https://github.com/Tencent/ncnn/issues/4489#issue-1561097873

Digital2Slave avatar Jan 29 '23 06:01 Digital2Slave

@Digital2Slave Thanks bro <3

nqthai309 avatar Jan 31 '23 09:01 nqthai309

@Digital2Slave Any update regarding this issue? I am also facing the same issue, I tried ONNX to NCNN approach also and torchscript > PNNX > NCNN but the output param file is different from provided by @FeiGeChuanShu . It seems he used a different approach :/

MjiS avatar Feb 09 '23 10:02 MjiS

@MjiS I change to use yolov8 segment model. You can refer wiki https://github.com/Digital2Slave/ncnn-android-yolov8-seg/wiki/Conver-yolov8-model-to-ncnn-model.

By the way, because the yolov5 segment model may different between versions. The convert NCNN model file maybe also different from @FeiGeChuanShu .

Digital2Slave avatar Feb 10 '23 02:02 Digital2Slave

@Digital2Slave Thank you for your guidance but I want to run segmentation in real time like yolov5-seg. There is no app for Yolov8s-seg model or do I need to make specific changes to it to run the segmentation model?

MjiS avatar Feb 10 '23 07:02 MjiS

@Digital2Slave Thank you for your guidance but I want to run segmentation in real time like yolov5-seg. There is no app for Yolov8s-seg model or do I need to make specific changes to it to run the segmentation model?

Refer https://github.com/Digital2Slave/ncnn-android-yolov8-seg

Digital2Slave avatar Feb 10 '23 08:02 Digital2Slave