tucan9389 / ObjectDetection-CoreML

An example running Object Detection using Core ML (YOLOv8, YOLOv5, YOLOv3, MobileNetV2+SSDLite)
https://github.com/motlabs/awesome-ml-demos-with-ios
MIT License
289 stars 51 forks source link

Support YOLOv8 #13

Open tucan9389 opened 1 year ago

tucan9389 commented 1 year ago

yolov8: https://github.com/ultralytics/ultralytics

At this moment(23.04.08), there is error when converting yolov8 models to Core ML. Once https://github.com/ultralytics/ultralytics/pull/1791 is merged, you can use the following steps. (Or you can use this PR alternatively.)

Pre-requirements

pip install ultralytics
pip install coremltools

Option 1) With shell

yolo export model=yolov8n.pt format=coreml nms

Option 2) With python script

# mian.py
from ultralytics import YOLO

if __name__ == '__main__':
    model = YOLO("yolov8n.pt", task='detect')  # load a pretrained model
    model.overrides['nms'] = True
    success = model.export(format="coreml")  # export the model to CoreML format
# in terminal
python main.py
# then you can see the `.mlpackage` or `.mlmodel` file in your current directory
# (btw you can check your current directory with `pwd` command)
tucan9389 commented 1 year ago
image
JaeungHyun commented 1 year ago

오.. 모바일에서 yolo_v8 성능이 잘 나오나요? v5가 프레임이 더 잘나온다고 하던데..

tucan9389 commented 1 year ago

오.. 이미 실험이 있나보군요. 정확도 대비 프레임이 중요할거같은데 아시는 소스가 있다면 공유 부탁드려도 될까요?

저는 다른모델과 비교를 할만큼 실험은 없어서요.. https://github.com/tucan9389/ObjectDetection-CoreML#infernece-time-ms

JaeungHyun commented 1 year ago

저도 오픈채팅방에서 지나가면서 본거라... 자료는 찾으면 공유해드리겠습니다

pseudo-jay commented 1 year ago

Request to add Yolov8 Pose and Segmentation in the demo app

tucan9389 commented 1 year ago

@pseudo-jay Hi jay, thanks for asking. Here are the related repos you can try:

I didn't implement it for yolov8 yet, but if you can make it, I’ll be appreciated your contribution.

glenn-jocher commented 1 year ago

Great news 😃! YOLOv8 now supports Apple's new CoreML *.mlpackage format natively ✅ in PR https://github.com/ultralytics/ultralytics/pull/4043 and published in ultralytics 8.0.150. Usage remains the same:

yolo export model=yolov8n.pt format=coreml  # produces yolov8n.mlpackage
yolo export model=yolov8n.pt format=mlmodel  # produces legacy yolov8n.mlmodel

To get this update:

Thank you for spotting this issue and letting us know. Please confirm if this update fixes the issue for you, and don't hesitate to report any other issues you find or feature requests you may have. Happy training with YOLOv8 🚀!