AI Traffic Signal Optimizer Using YOLOv8 – Django Final Year Project
Back to ProjectCreate and activate a virtual environment, then install dependencies.
python -m venv venv source venv/bin/activate # macOS/Linux venv\Scripts\Activate.ps1 # Windows PowerShell pip install -r requirements.txt
This installs Django, Django REST Framework, django-environ, ultralytics, opencv-python, pillow, and numpy. The ultralytics package pulls in torch and torchvision, so this step may take a few minutes.
Copy the example environment file and adjust values as needed.
cp .env.example .env
Set SECRET_KEY, DEBUG, and ALLOWED_HOSTS. If no .env file is present, safe development defaults are used automatically.
python manage.py migrate python manage.py seed_demo_data
This creates a demo junction with four lanes (North, South, East, West) ready for testing.
python manage.py runserver
Visit the dashboard at http://127.0.0.1:8000/, live detection at /junction/1/detect/, and analytics at /junction/1/analytics/.
Run simulated traffic cycles without needing footage:
python manage.py simulate_traffic_cycle
Note: the first detection run automatically downloads the YOLOv8 nano weights file, which requires an internet connection once.
python manage.py test signals_app
Our team is here to assist you with installation and setup.