Traffic Reducer requires Python, a small set of pip packages, and a few supporting assets — YOLO weight files, an optional FFmpeg binary, and a pre-trained sklearn model. This page covers every prerequisite and explains what each component does, so you have a complete picture before running the installation command.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Xander44-4/traffic_reducer/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before installing, confirm that your system meets the following requirements:-
Python 3.10 or 3.11 — required for compatibility with
ultralytics,scikit-learn, and the rest of the dependency stack. Python 3.12+ may work but is not tested. Verify with: -
pip — the standard Python package manager, included with all Python 3 distributions. Verify with:
-
Internet connection (for YouTube mode) —
yt-dlpmust resolve a live HLS URL from YouTube each time the YouTube source is activated. Local video mode works fully offline.
Python packages
All required packages are listed inrequirements.txt at the project root:
| Package | Version note | Purpose |
|---|---|---|
flask | Any current stable release | Web server, Jinja2 template rendering, and REST API routing for the dashboard |
opencv-python | Any current stable release | Frame capture from local video files and the FFmpeg pipe, zone polygon testing, bounding-box drawing, and JPEG encoding |
ultralytics | Any current stable release | YOLOv8 model loading and inference; also installs imageio-ffmpeg as a dependency |
yt-dlp | Any current stable release | Extracts a direct HLS stream URL from a YouTube live link so FFmpeg can pipe raw video frames |
pandas | Any current stable release | Data handling utilities used across the processing pipeline |
numpy | Any current stable release | Numerical operations — polygon centroid tests, argmax phase selection, HSV colour ratio calculations for emergency detection |
joblib | Any current stable release | Alternative deserialiser for the pre-trained sklearn .pkl model file; used as a fallback when pickle.load fails |
scikit-learn | Any current stable release | Provides the runtime environment for the pre-trained signal-phase classification model |
On Windows, use
py instead of python if the python command is not recognised. On macOS and Linux, use python3 and pip3 to avoid accidentally targeting a system Python 2 installation.YOLOv8 model weights
Traffic Reducer ships with three YOLO weight files in the repository root:| File | Size | Notes |
|---|---|---|
yolov8m.pt | Medium | Default — best accuracy for multi-vehicle intersection scenes |
yolov8s.pt | Small | Faster inference; used automatically if yolov8m.pt is absent |
traffic_app/app.py:
yolov8m.pt from its model registry on first run. Keep at least one .pt file in the project root to avoid this network request at startup.
FFmpeg
Traffic Reducer uses FFmpeg to decode the YouTube HLS stream into raw BGR frames that OpenCV can process. You do not need to install FFmpeg manually. Theimageio-ffmpeg package — installed automatically as a dependency of ultralytics — bundles a platform-appropriate FFmpeg binary and exposes it at runtime:
subprocess.Popen when opening a YouTube stream. No PATH configuration or system-level FFmpeg installation is required.
Pre-trained sklearn model
The repository includes a pre-trained scikit-learn model for signal-phase classification:.pkl file is loaded at server startup by traffic_app/app.py using pickle.load with a joblib.load fallback. It is used by the POST /predict endpoint to classify the appropriate signal phase from vehicle count inputs.
Verifying the installation
Oncepip install -r requirements.txt completes, run the server to confirm everything is in order: