Convert Yolov8 to CoreML and use it on iPhone

MLBoy
1 min readJun 6, 2023

--

Use object detection AI on your smartphone

Yolov8 is a popular object detection model.
In this article, we will make Yolov8 available for iOS.

Method

Install Yolov8 and download model checkpoint.
(A list of model checkpoints can be found in the ultralytics repository above.)

pip install ultralytics
wget https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8s.pt

If you get the following error, change the following line in yolo/engine/exporter.py of the ultralytics library (line 390).

# f = self.file.with_suffix(‘.mlmodel’)
# ↓↓↓
f = self.file.with_suffix(‘.mlpackage’)

A .mlpackage file (CoreML) is saved in the same directory as the pt file.

The sample to run with the camera of iOS is as follows.

🐣

I’m a freelance engineer.
Work consultation
Please feel free to contact us with a brief development description.
rockyshikoku@gmail.com

I am creating applications using machine learning and AR technology.

I send machine learning / AR related information.

GitHub

Twitter
Medium

--

--