Oriented Bounding Boxes with YOLOv8
Getting started with YOLOv8
In YOLOv8.1, oriented bounding boxes (OBB) for object detection were introduced.
This means that we can now detect objects at various angles.
You can see the dramatic difference when we compare an angled image annotated with YOLOv8 OBB vs. regular object detection.
Here’s the setup for downloading and running YOLOv8 object detection with OBB.
Choose a model:
Download the model:
from ultralytics import YOLO
model = YOLO("yolov8n-obb.pt")
Run inference:
results = model("images/image.jpg", save=True, show=True)
(Optional): I’ve noticed that resizing the image sometimes gives better results. If you want to try it out:
import torchvision.transforms as transforms
from PIL import Image
image = Image.open("images/image.jpg")
transform = transforms.Resize(1024)
resized_image = transform(image)
The object detection model is not perfect!
See, for example, what happens if we have an overview image at a slight angle.
We fail to classify the smaller ships at the back of the image.
Further Reading
If you want to learn more about programming and, specifically, machine learning, see the following course:
Note: If you use my links to order, I’ll get a small kickback.