Open yl1994yl opened 6 months ago
from ultralytics import YOLO
model = YOLO("yolov10n.pt") model.export(format="ncnn") ncnn_model = YOLO("./yolov10n_ncnn_model") results = ncnn_model("bus.jpg") print()
Hello jameslahm Wang Ao] 你好。 最近什么样 ?你好吗 ? I would like to write python about with Ai and Data Center. Please you advice me about with a kind of program run on HTML
多谢谢 Thank you so much
Thanks for your interest! It seems that there is no torch.topk
in yolov8. Could you please confirm that? Thank you!
Thanks for your interest! It seems that there is no
torch.topk
in yolov8. Could you please confirm that? Thank you!
I confirmed that there is no topk layer in ncnn model of yolov8, but it do have topk in yolov10 v10postprocess. Following the code:
Thanks. This issue may rely on ncnn to add the support for torch.topk
.
要么按照ncnn的教程添加topk算子,要么就像yolov8把后处理部分全砍了,一步一步自己手写实现。。
Maybe,it can help you.https://zhuanlan.zhihu.com/p/699632697
Maybe,it can help you.https://zhuanlan.zhihu.com/p/699632697
Great thanks for suggestions! I tried and it works!
Maybe,it can help you.https://zhuanlan.zhihu.com/p/699632697
But the inference speed is not faster than yolov5, did you get the same result? Thanks for replying!
when i exported model to ncnn, it cannot work. The error message is "layer torch.topk not exists or registered", but i try use ncnn in yolov8 which also has the layer torch.topk and it succeed, so i think the layer error is not the key. Relative infomation is followed, thank you for suggestions!
Ultralytics YOLOv8.1.34 🚀 Python-3.9.19 torch-2.0.1+cu117 CPU (Intel Xeon E5-2699 v4 2.20GHz) YOLOv10n summary (fused): 285 layers, 2762608 parameters, 0 gradients, 8.6 GFLOPs
PyTorch: starting from 'yolov10n.pt' with input shape (1, 3, 640, 640) BCHW and output shape(s) (1, 300, 6) (10.9 MB)
TorchScript: starting export with torch 2.0.1+cu117... TorchScript: export success ✅ 30.6s, saved as 'yolov10n.torchscript' (11.1 MB)
NCNN: starting export with NCNN 1.0.20240410... NCNN: running './pnnx yolov10n.torchscript ncnnparam=yolov10n_ncnn_model/model.ncnn.param ncnnbin=yolov10n_ncnn_model/model.ncnn.bin ncnnpy=yolov10n_ncnn_model/model_ncnn.py pnnxparam=yolov10n_ncnn_model/model.pnnx.param pnnxbin=yolov10n_ncnn_model/model.pnnx.bin pnnxpy=yolov10n_ncnn_model/model_pnnx.py pnnxonnx=yolov10n_ncnn_model/model.pnnx.onnx fp16=0 device=cpu inputshape="[1, 3, 640, 640]"' pnnxparam = yolov10n_ncnn_model/model.pnnx.param pnnxbin = yolov10n_ncnn_model/model.pnnx.bin pnnxpy = yolov10n_ncnn_model/model_pnnx.py pnnxonnx = yolov10n_ncnn_model/model.pnnx.onnx ncnnparam = yolov10n_ncnn_model/model.ncnn.param ncnnbin = yolov10n_ncnn_model/model.ncnn.bin ncnnpy = yolov10n_ncnn_model/model_ncnn.py fp16 = 0 optlevel = 2 device = cpu inputshape = [1,3,640,640]f32 inputshape2 = customop = moduleop = ############# pass_level0 inline module = torch.nn.modules.linear.Identity inline module = ultralytics.nn.modules.block.Attention inline module = ultralytics.nn.modules.block.Bottleneck inline module = ultralytics.nn.modules.block.C2f inline module = ultralytics.nn.modules.block.C2fCIB inline module = ultralytics.nn.modules.block.CIB inline module = ultralytics.nn.modules.block.DFL inline module = ultralytics.nn.modules.block.PSA inline module = ultralytics.nn.modules.block.RepVGGDW inline module = ultralytics.nn.modules.block.SCDown inline module = ultralytics.nn.modules.block.SPPF inline module = ultralytics.nn.modules.conv.Concat inline module = ultralytics.nn.modules.conv.Conv inline module = ultralytics.nn.modules.head.v10Detect inline module = torch.nn.modules.linear.Identity inline module = ultralytics.nn.modules.block.Attention inline module = ultralytics.nn.modules.block.Bottleneck inline module = ultralytics.nn.modules.block.C2f inline module = ultralytics.nn.modules.block.C2fCIB inline module = ultralytics.nn.modules.block.CIB inline module = ultralytics.nn.modules.block.DFL inline module = ultralytics.nn.modules.block.PSA inline module = ultralytics.nn.modules.block.RepVGGDW inline module = ultralytics.nn.modules.block.SCDown inline module = ultralytics.nn.modules.block.SPPF inline module = ultralytics.nn.modules.conv.Concat inline module = ultralytics.nn.modules.conv.Conv inline module = ultralytics.nn.modules.head.v10Detect
############# pass_level1 ############# pass_level2 ############# pass_level3 ############# pass_level4 ############# pass_level5 ############# pass_ncnn BinaryOp remainder not supported yet BinaryOp floor_divide not supported yet ignore torch.topk torch.topk_56 param dim=-1 ignore torch.topk torch.topk_56 param k=300 ignore torch.topk torch.topk_56 param largest=True ignore torch.topk torch.topk_56 param sorted=True ignore torch.gather torch.gather_37 param dim=1 ignore torch.gather torch.gather_38 param dim=1 ignore torch.topk torch.topk_57 param dim=-1 ignore torch.topk torch.topk_57 param k=300 ignore torch.topk torch.topk_57 param largest=True ignore torch.topk torch.topk_57 param sorted=True ignore torch.gather torch.gather_39 param dim=1 NCNN: export success ✅ 4.4s, saved as 'yolov10n_ncnn_model' (9.0 MB)
Export complete (66.0s) Results saved to /mnt/disk5/yinliang/notebooks/yolov10-main Predict: yolo predict task=detect model=yolov10n_ncnn_model imgsz=640
Validate: yolo val task=detect model=yolov10n_ncnn_model imgsz=640 data=coco.yaml
Visualize: https://netron.app WARNING ⚠️ Unable to automatically guess model task, assuming 'task=detect'. Explicitly define task for your model, i.e. 'task=detect', 'segment', 'classify','pose' or 'obb'. Loading yolov10n_ncnn_model for NCNN inference... layer torch.topk not exists or registered