Easy to use YOLOWorld Convert for iOS

MLBoy
2 min readFeb 26, 2024

You can set your favorite object

YOLOWorld allows you to set up a class that detects objects using text, but
using the pip package makes it easy to use with just a few lines of code.

install

pip install ultralytics
from ultralytics import YOLOWorld
model = YOLOWorld('yolov8l-world.pt')

set class

model.set_classes(["donuts"])

Now it will detect donuts.

execution

results = model.predict('donuts.jpg',save=True)

Convert to Core ML

What’s more, you can convert detection models with custom classes to Core ML for iOS and macOS.

import torch
from ultralytics import YOLO

with torch.no_grad():
model = YOLO('yolov8s-world.pt')

custom_classes = ["donuts"]
model.set_classes(custom_classes)

model.save("donuts_yolov8s.pt")
model = YOLO("donuts_yolov8s.pt")
model.export(format="coreml", nms=True)

Now you have a yolov8s Core ML model for donut detection.

Good luck ultralytics.

🐣

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

--

--