The defaultDocumentation 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.
app.run(debug=True) configuration in app.py is intended for local development only. It enables the interactive debugger, exposes the Werkzeug reloader (disabled here via use_reloader=False), and binds only to 127.0.0.1, making the server unreachable from other machines. This page covers the changes needed to run Traffic Reducer reliably and securely in a production environment.
Disable debug mode
Edit the final block inapp.py to turn off debug mode and bind to all network interfaces:
host='0.0.0.0' makes the server listen on all available interfaces so that other machines on the network can reach the dashboard and MJPEG stream.
Run with a production WSGI server
Flask’s built-in server is single-threaded and not hardened for production traffic. Replace it with a production-grade WSGI server:GPU acceleration
If the production machine has a CUDA-capable GPU, install the GPU-enabled build of PyTorch before installing Ultralytics. This allows YOLOv8 to run inference on the GPU, significantly reducing per-frame latency:cu121 with the CUDA version matching your driver (e.g., cu118 for CUDA 11.8). Ultralytics will automatically use the GPU when PyTorch detects a CUDA device.
Fix MODEL_PATH
Before deploying, update the hardcodedMODEL_PATH in app.py to an absolute path valid on the production machine:
/predict endpoint will return a 500 error for any request that does not use live_mode.
Run as a systemd service (Linux)
To have Traffic Reducer start automatically on boot and restart on failure, create a systemd unit file:/etc/systemd/system/traffic-reducer.service, then enable and start it:
Network access
By default, without thehost='0.0.0.0' change described above, the server binds only to 127.0.0.1:5000 and is not reachable from other machines. After setting host='0.0.0.0', any machine on the same network can access the dashboard at http://<server-ip>:5000.
The MJPEG stream served at
/video_feed sends a continuous sequence of JPEG frames encoded at quality 78–82. This is bandwidth-intensive, particularly on slow or wireless networks. If multiple clients need to view the stream simultaneously, consider proxying through nginx with buffering enabled to absorb burst traffic and reduce the load on the Flask/WSGI process.