This repository contains a highly configurable two-stage-tracker that adjusts to different deployment scenarios. It can jointly perform multiple object tracking and instance segmentation (MOTS). The detections generated by YOLOv8, a family of object detection architectures and models pretrained on the COCO dataset, are passed to the tracker of your choice. Supported ones at the moment are: DeepOCSORT, OCSORT, StrongSORT, ByteTrack and BoTSORT, . They can track any object that your Yolov8 model was trained to detect.
pip install -r requirements.txt
$ python track.py
-
Detection mode
$ python track.py --yolo-weights yolov8n.pt # bboxes only yolov8n-seg.pt # bboxes + segmentation masks
-
Tracking methods
$ python track.py --tracking-method ocsort deepocsort strongsort bytetrack botsort
-
Tracking sources
Tracking can be run on most video formats
$ python track.py --source 0 # webcam img.jpg # image vid.mp4 # video path/ # directory path/*.jpg # glob 'https://youtu.be/Zgi9g1ksQHc' # YouTube
-
Select Yolov8 model
There is a clear trade-off between model inference speed and overall performance. In order to make it possible to fulfill your inference speed/accuracy needs you can select a Yolov8 family model for automatic download. You can also select image size of 640 or 1280.
$ python track.py --source 0 --yolo-weights yolov8n.pt --img 640 yolov8s.pt yolov8m.pt yolov8l.pt yolov8x.pt --img 1280 ...
-
Filter tracked classes
By default the tracker tracks all MS COCO classes. If you want to track a subset of the classes that you model predicts, add their corresponding index after the classes flag.
python track.py --source 0 --yolo-weights yolov8s.pt --classes 16 17 # Track cats and dogs, only
Here is a list of all the possible objects that a Yolov8 model trained on MS COCO can detect. Notice that the indexing for the classes in this repo starts at zero