Multi-object tracking for uploaded videos, using YOLOv8 and ByteTrack in a Flask web app.
Example frame from the tracking workflow. Upload a video to produce your own annotated MP4.
- Detects 80 COCO object classes with YOLOv8n and assigns persistent track IDs with ByteTrack.
- Accepts MP4, AVI, MOV, MKV, and WebM uploads up to 100 MB, and checks each file's contents before it is processed.
- Returns an annotated MP4 with a label, confidence score, and track ID on each object.
- Shows measured values for each video: unique track IDs, detections, frames processed, and processing time.
- Provides a JSON API with a health check, an OpenAPI 3.0 spec, and consistent JSON errors.
- Runs on CPU, loads the model once at startup, and downloads the weights on first start.
git clone https://github.com/Shashwat-19/Object-Detection.git && cd Object-Detection
python3.11 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt
export PORT=8000 && gunicorn app:app --bind 127.0.0.1:$PORT --timeout 600 --workers 1 --worker-class gthread --threads 4The first start downloads the model weights, yolov8n.pt (about 6.5 MB), into the project folder. Wait for Model loaded successfully in the log, then open http://127.0.0.1:8000.
On macOS, the pinned +cpu PyTorch builds are not available. Follow step 3 in the quickstart instead.
Upload the sample clip. The server redirects to the result page, and the file parameter names the output:
curl -s -o /dev/null -D - -F video=@samples/sample.mp4 http://127.0.0.1:8000/uploadHTTP/1.1 302 FOUND
Content-Type: text/html; charset=utf-8
Location: /result/?file=track_sample_8a78d9517b_29dc62e9a8.mp4Fetch the measured values for that video:
curl -s http://127.0.0.1:8000/static/outputs/track_sample_8a78d9517b_29dc62e9a8.json{"frames_processed": 40, "total_detections": 133, "unique_track_ids": 15, "processing_seconds": 0.57}Errors return JSON when the request asks for it (X-Requested-With: XMLHttpRequest or Accept: application/json):
{"error":"The file is not a supported video. Its contents do not match the file extension."}- Quickstart: from a fresh clone to a tracked video.
- API reference: every route, with examples and status codes.
- Technical report: architecture, model settings, measured performance, and known limitations.
- OpenAPI spec: the machine-readable contract.
| Area | Tools |
|---|---|
| Detection and tracking | Ultralytics YOLOv8 (8.4.49), ByteTrack |
| Web app | Flask 3.1, Gunicorn 23 |
| Computer vision | OpenCV, NumPy |
| Runtime | PyTorch 2.11 (CPU), Python 3.11 |
| Front end | Bootstrap 5.3, Bootstrap Icons, vanilla JavaScript |
| Tests | pytest |
pip install -r requirements-dev.txt
pytestThe tests use a fake model, so they do not download weights or run inference.
Released under the MIT License.
Shashwat · github.com/Shashwat-19
