Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Official Support ✅ for Ultralytics YOLOv8 NCNN export #4846

Open
glenn-jocher opened this issue Jul 7, 2023 · 9 comments
Open

Official Support ✅ for Ultralytics YOLOv8 NCNN export #4846

glenn-jocher opened this issue Jul 7, 2023 · 9 comments

Comments

@glenn-jocher
Copy link

glenn-jocher commented Jul 7, 2023

I have great news 😃! I've recently added official support for Ultralytics YOLOv8 NCNN export ✅ in PR ultralytics/ultralytics#3529 with the help of @nihui which is part of ultralytics==8.0.129. NCNN works for all tasks including Detect, Segment, Pose and Classify.

You can now export with CLI:

yolo export model=yolov8n.pt format=ncnn

or Python:

from ultralytics import YOLO

# Create a model
model = YOLO('yolov8n.pt')

# Export the model to NCNN with arguments
model.export(format='ncnn', half=True, imgsz=640)

Output is a yolov8n_ncnn_model/ directory containing model.bin, model.param and metadata.yaml, along with extra PNNX files. For details see https://github.com/pnnx/pnnx README.

To get this update:

  • Git – Run git pull from within your ultralytics/ directory or run git clone https://github.com/ultralytics/ultralytics again
  • Pip – Update with pip install -U ultralytics
  • Notebooks – Check out the updated notebooks Run on Gradient Open In Colab Open In Kaggle
  • Docker – Run sudo docker pull ultralytics/ultralytics:latest to update your image Docker Pulls

Please let us know if NCNN export is working correctly for you, and don't hesitate to report any other issues you find or feature requests you may have. Happy training with YOLOv8 🚀!

@superbayes
Copy link

superbayes commented Jul 10, 2023

@nihui @triple-Mu How to use the officially exported yolov8-model file to complete inference tasks, using ncnn in c++?
the tasks including Detect, Segment, Pose and Classify.
could you provide code examples?

@superbayes
Copy link

i have seen this link,but not try
code demo

@13185742215
Copy link

could you provide an example for yolov8-pose inference on ncnn in python?

@glenn-jocher
Copy link
Author

glenn-jocher commented Jul 19, 2023

@13185742215 yes you can simply do this:

pip install ultralytics

yolo export format=ncnn model=yolov8n-pose.pt
yolo predict model=yolov8n-pose_ncnn_model source=path/to/image.jpg

The NCNN exported YOLOv8 models can be used just like a PyTorch model with the ultralytics package. See https://docs.ultralytics.com/modes/predict/ for other ways to run inference.

@trlsmax
Copy link

trlsmax commented Jul 26, 2023

Hope there are examples of ncnn in c++.

@palevi67
Copy link

palevi67 commented Sep 7, 2023

I see there is no yolov8.cpp in the examples folder, it would be nice an example that uses utralitics export tool models. I have found some examples in the internet, but none of them are working with ultralitics export models!

@wkt
Copy link

wkt commented Sep 16, 2023

@nihui
Copy link
Member

nihui commented Aug 19, 2024

yolov8 example #5506

@nihui
Copy link
Member

nihui commented Jan 8, 2025

hi, yolov8 examples are updated with full support for detection, segmentation, classification, pose estimation and obb
https://github.com/Tencent/ncnn/tree/master/examples

android demo
https://github.com/nihui/ncnn-android-yolov8

detailed instruction (zh)
https://zhuanlan.zhihu.com/p/16030630352

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants