First, install the supervision pip package:
Once you have installed supervision, you are ready to load your data and start writing logic to filter detections.
First, we are going to load our dataset into a supervision.DetectionDataset() object. This object will contain information about all the images in a dataset. You can load datasets from many different model types, from YOLO to MMDetection. For this guide, we will use the
YOLOv9
data loader.
You can load data using the following code:
Above, replace "microsoft-coco/9" with the model ID of a YOLOv9 model hosted on Roboflow.
To upload a model to Roboflow, first install the Roboflow Python package:
Then, create a new Python file and paste in the following code:
In the code above, add your API key and the path to the model weights you want to upload. Learn how to retrieve your API key. Your weights will be uploaded to Roboflow. Your model will shortly be accessible over an API, and available for use in Inference. To learn more about uploading model weights to Roboflow, check out our full guide to uploading weights to Roboflow.
Replace the ... with the response object from your model.
Supervision has two annotators that let you visualize detections from a computer vision model:
1. BoxAnnotator, to plot bounding boxes.
2. MaskAnnotator, to plot segmentation masks.
You can use the following code to plot bounding boxes:
To plot segmentation masks, replace BoundingBoxAnnotator() with MaskAnnotator(). This will use the segmentation mask annotator for visualizing detections.
You can preview what different annotators look like using the following interactive widget:
supervision provides an extensive range of functionalities for working with computer vision models. With supervision, you can:
1. Process and filter detections and segmentation masks from a range of popular models (YOLOv5, Ultralytics YOLOv8, MMDetection, and more).
2. Process and filter classifications.
3. Compute confusion matrices.
And more! To learn about the full range of functionality in supervision, check out the supervision documentation.