Python YOLOv8 OpenCV Streamlit Plotly W&B License
Production-grade object detection and tracking - YOLOv8 + BoT-SORT/ByteTrack, interactive Streamlit dashboard, Plotly analytics, MP4 export and optional W&B logging.
Built by Md. Musa Islam Fahad Β· CSE (Data Science) Β· Daffodil International University
VisionTrack AI is a production-grade, multi-object detection and tracking system. It combines YOLOv8 (Ultralytics) for fast and accurate detection with BoT-SORT or ByteTrack to assign persistent IDs and render movement trails across frames for all 80 COCO object classes.
An interactive Streamlit dashboard exposes full control over models, trackers, and thresholds, and renders live Plotly analytics (FPS timeline, object count chart, class breakdown, track timeline). Sessions can optionally be logged to Weights & Biases, and the annotated output is exportable as an MP4 video.
The system works on:
- π₯ Live webcam streams
- π Pre-recorded video files
- πΌοΈ Static images
| Feature | Details |
|---|---|
| π€ Detection Model | YOLOv8 (n / s / m / l / x variants) - pre-trained on COCO 80 classes |
| π Dual Tracker Support | BoT-SORT (appearance + motion) Β· ByteTrack (motion only) - switchable from UI |
| π¨ Rich Visualisation | Colour-coded bounding boxes, persistent track IDs, movement trails |
| π·οΈ Class Filter | Filter any of the 80 COCO classes directly from the sidebar |
| π Live Analytics | Plotly charts - FPS timeline, object count, class breakdown, track timeline |
| π₯ MP4 Export | Download the fully annotated video from the dashboard |
| π‘ W&B Logging | Per-frame FPS, object count, session summary, model config (optional) |
| π· Multi-source Input | Webcam, video file, or image - selectable from the UI |
| π³ Docker Ready | Full Dockerfile for containerised CPU or GPU deployment |
| βοΈ Multi-platform Deploy | Streamlit Cloud Β· HuggingFace Spaces Β· Docker |
| Layer | Technology |
|---|---|
| Language | Python 3.10+ |
| Detection Model | YOLOv8 (Ultralytics) |
| Trackers | BoT-SORT (appearance + Kalman filter) Β· ByteTrack (motion-only) |
| Computer Vision | OpenCV |
| Deep Learning Backend | PyTorch |
| UI / Dashboard | Streamlit 1.35 |
| Analytics Charts | Plotly |
| Experiment Tracking | Weights & Biases (optional) |
object_detection_tracker/
β
βββ app.py # Streamlit main application β entry point
β
βββ src/
β βββ tracker.py # ObjectTracker class (YOLOv8 + BoT-SORT engine)
β
βββ utils/
β βββ analytics.py # SessionStats + Plotly chart builders
β βββ video_utils.py # Video I/O helpers (read, write, frame extraction)
β βββ logger.py # W&B experiment logger
β
βββ .streamlit/
β βββ config.toml # Streamlit theme + server configuration
β
βββ requirements.txt # Python dependencies
βββ Dockerfile # Container build definition
βββ .env.example # Environment variable template
βββ .gitignore
βββ README.md
git clone https://github.com/MusaIslamFahad/codealpha_tasks.git
cd codealpha_tasks/CodeAlpha_Object_Detection_and_Trackingpython -m venv venv # On Windows venv\Scripts\activate # On macOS / Linux source venv/bin/activate
pip install -r requirements.txt
Or install manually:
pip install ultralytics opencv-python streamlit plotly wandb python-dotenv
GPU Acceleration: PyTorch is installed automatically via
ultralytics. For CUDA support, install the GPU-enabled build from pytorch.org before runningpip install -r requirements.txt.
cp .env.example .env
# Edit .env and add: WANDB_API_KEY=your_key_herestreamlit run app.py
# Open http://localhost:8501streamlit run app.py
Open http://localhost:8501 in your browser. Use the sidebar to:
- Select input source (webcam / video file / image)
- Choose model variant (
yolov8nβyolov8x) - Select tracker (
BoT-SORTorByteTrack) - Set confidence and IOU thresholds
- Filter specific COCO classes
- Enter your W&B API key (optional)
The main panel shows the annotated live feed, Plotly analytics charts below, and a download button for the MP4 export.
| Key | Action |
|---|---|
q |
Quit / stop stream |
# Build the image docker build -t visiontrack-ai . # Run on CPU docker run -p 8501:8501 visiontrack-ai # Run with GPU docker run --gpus all -p 8501:8501 visiontrack-ai # Open http://localhost:8501
- Create a new Space at huggingface.co/spaces
- Choose Streamlit SDK
- Push this repository to the Space:
git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/visiontrack-ai git push hf main
- (Optional) Apply for a Free GPU grant in your Space settings for real-time inference
- Fork this repository to your GitHub account
- Go to share.streamlit.io and sign in
- Select repo β
app.pyβ Deploy - Add secrets in the Streamlit Cloud dashboard if using W&B:
- Key:
WANDB_API_KEYβ Value: your API key
- Key:
- Create a free account at wandb.ai
- Get your API key from Settings β API Keys
- Paste it in the sidebar W&B API key field, or add it to
.env
Each processing session automatically logs:
| Metric | Description |
|---|---|
| Per-frame FPS | Inference speed over time |
| Object count | Number of detections per frame |
| Unique tracks | Total distinct objects tracked per session |
| Avg FPS / Peak objects | Session-level summary stats |
| Model config | Variant, confidence, IOU, tracker, and class filter settings |
Input (Image / Video File / Webcam)
β
βΌ
βββββββββββββββ
β YOLOv8 β β Pre-trained on COCO (80 classes)
β Detector β β Configurable: n / s / m / l / x variant
ββββββββ¬βββββββ
β raw detections (bbox, class, confidence)
βΌ
ββββββββββββββββββββββββββββ
β Tracker β β BoT-SORT: appearance embedding + Kalman filter
β (selectable from UI) β β ByteTrack: motion-only, lighter & faster
ββββββββ¬ββββββββββββββββββββ
β tracked detections (bbox, class, track_id)
βΌ
βββββββββββββββββββββββ
β Annotation Engine β β Bounding boxes, colour-coded IDs, trails, FPS HUD
ββββββββ¬βββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββ ββββββββββββββββββ
β Streamlit Dashboard (app.py) ββββββΆβ W&B Logger β (optional)
β ββ Live annotated feed β β (logger.py) β
β ββ Plotly analytics charts β ββββββββββββββββββ
β β ββ FPS timeline β
β β ββ Object count chart β
β β ββ Class breakdown β
β β ββ Track timeline β
β ββ MP4 download button β
βββββββββββββββββββββββββββββββββ
Step-by-step:
- Detection: YOLOv8 processes each frame and returns bounding boxes, class labels, and confidence scores.
- Tracking: The selected tracker (BoT-SORT or ByteTrack) matches detections across frames and assigns persistent IDs.
- Annotation: The annotation engine draws bounding boxes, colour-coded track IDs, and movement trails on each frame.
- Dashboard: Streamlit renders the annotated frames live alongside Plotly charts for FPS, object count, class breakdown, and track timelines.
- Export: The processed video is written to disk by
video_utils.pyand made available as an MP4 download. - Logging: If W&B is configured,
logger.pypushes per-frame and session-level metrics in real time.
# Swap model by changing one line in app.py or src/tracker.py model = YOLO("yolov8n.pt") # Nano - fastest, lowest VRAM model = YOLO("yolov8s.pt") # Small model = YOLO("yolov8m.pt") # Medium model = YOLO("yolov8l.pt") # Large model = YOLO("yolov8x.pt") # Extra-large - most accurate
| Model | Size | Speed (CPU) | mAP50-95 | Best For |
|---|---|---|---|---|
| yolov8n | 6.2 MB | ~8 FPS | 37.3 | CPU / edge / Streamlit Cloud |
| yolov8s | 21.5 MB | ~5 FPS | 44.9 | Balanced speed + accuracy |
| yolov8m | 49.7 MB | ~3 FPS | 50.2 | Higher accuracy |
| yolov8l | 83.7 MB | ~2 FPS | 52.9 | High accuracy |
| yolov8x | 130.5 MB | ~1 FPS | 53.9 | Max accuracy (GPU recommended) |
Recommendation: Use
yolov8non CPU or Streamlit Cloud. Useyolov8mor larger on a dedicated GPU.
| Tracker | Algorithm | Speed | ID Stability | Best For |
|---|---|---|---|---|
| BoT-SORT | Appearance embedding + Kalman filter | Medium | βββββ | Crowded scenes, re-identification |
| ByteTrack | Motion-only (IoU matching) | Fast | βββ | Sparse scenes, low-VRAM environments |
ultralytics>=8.0.0
opencv-python>=4.8.0
torch>=2.0.0
streamlit>=1.35.0
plotly>=5.18.0
wandb>=0.16.0
python-dotenv>=1.0.0
numpy>=1.24.0
Python version: 3.10 or higher
Click to expand full class list
person bicycle car motorcycle airplane bus train truck boat traffic light fire hydrant stop sign parking meter bench bird cat dog horse sheep cow elephant bear zebra giraffe backpack umbrella handbag tie suitcase frisbee skis snowboard sports ball kite baseball bat baseball glove skateboard surfboard tennis racket bottle wine glass cup fork knife spoon bowl banana apple sandwich orange broccoli carrot hot dog pizza donut cake chair couch potted plant bed dining table toilet tv laptop mouse remote keyboard cell phone microwave oven toaster sink refrigerator book clock vase scissors teddy bear hair drier toothbrush
Contributions are welcome! If you'd like to improve the project:
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -m 'Add some feature') - Push to the branch (
git push origin feature/your-feature) - Open a Pull Request
Md. Musa Islam Fahad
CSE (Data Science) Β· Daffodil International University, Dhaka
π§ musa.islam.fahad@gmail.com
π Portfolio Β· GitHub Β· LinkedIn
This project is licensed under the MIT License - see LICENSE for details.
- Ultralytics for YOLOv8, BoT-SORT, and ByteTrack integration
- OpenCV for computer vision utilities
- Streamlit for the dashboard framework
- Plotly for interactive analytics charts
- Weights & Biases for experiment tracking infrastructure
- CodeAlpha for the internship opportunity and project brief
β If you found this useful or built something cool on top of it, drop a star. It helps a lot!