Are you ready to dive into the world of computer vision? With the Supervision package, loading datasets, drawing detections on images, or counting how many detections are in a zone has never been easier. Let’s explore how to set up Supervision and start building your computer vision applications!
Installation
To get started, you’ll need to install the Supervision package in a Python=3.8 environment. Simply run the following command:
pip install supervision
For more detailed information on using conda, mamba, or installing from source, refer to the installation guide.
Quick Start
Supervision is designed to be model agnostic, meaning you can plug in any classification, detection, or segmentation model. To get you started, here’s how to use a YOLO model:
import cv2
import supervision as sv
from ultralytics import YOLO
image = cv2.imread(...)
model = YOLO('yolov8s.pt')
result = model(image)[0]
detections = sv.Detections.from_ultralytics(result)
len(detections) # Outputs: 5
Understanding the Code: The Delivery Analogy
Let’s imagine your code is like a delivery service. Here’s a breakdown of how it works:
- import cv2: This is like your delivery van. You need it to transport your packages (images) from one place to another.
- model = YOLO(‘yolov8s.pt’): This is your driver, trained to recognize various delivery addresses (features in images).
- result = model(image)[0]: The driver takes the package to its destination, finding the addresses (features) along the way.
- detections = sv.Detections.from_ultralytics(result): This creates an inventory list of all successful deliveries (detections) made by the driver.
- len(detections): Finally, you check how many successful deliveries were made. In this case, it’s 5.
Working with Datasets
Supervision also comes with powerful utilities to manage datasets. You can load, split, merge, and save datasets in different formats. Here’s how to load a dataset from COCO format:
from roboflow import Roboflow
import supervision as sv
project = Roboflow().workspace(WORKSPACE_ID).project(PROJECT_ID)
dataset = project.version(PROJECT_VERSION).download('coco')
ds = sv.DetectionDataset.from_coco(
images_directory_path=dataset.location['train'],
annotations_path=dataset.location['train_annotations']['coco.json'],
)
path, image, annotation = ds[0] # Loads image on demand
Additional Functionalities with Datasets
With Supervision, you can also:
- Split a Dataset: Easily divide your dataset into training, validation, and test sets.
train_dataset, test_dataset = dataset.split(split_ratio=0.7)
ds_merged = sv.DetectionDataset.merge([ds_1, ds_2])
Troubleshooting
While working with Supervision, you may encounter some issues. Here are a few troubleshooting tips:
- Installation Issues: Ensure that you have the correct Python version installed.
- Import Errors: Double-check that you’ve properly installed Supervision and any other required packages.
- Model Not Found: Ensure that the model path points to a valid YOLO model file.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Learn More
Excited to learn more about using Supervision? Check out our how-to guides, explore end-to-end examples, and refer to the cheatsheet for quick references!
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

