MahaTraffic: AI Traffic Prediction and Smart Signal System for Pune (Django + LightGBM + YOLOv8)
Back to ProjectSet aside about 30 minutes. Most of that is waiting for pip and copying a big folder. Let's go step by step.
Place the ML artifacts. Download artifacts.zip, extract it, and put the artifacts folder inside mahatraffic/ml/. The final path must look like mahatraffic/ml/artifacts/models/. Double-check this. It's the number one reason the app fails.
Open a terminal in the project folder.
cd mahatraffic
Create and activate a virtual environment.
python -m venv venv
# Windows
venv\Scripts\activate
# macOS / Linux
source venv/bin/activate
You should see (venv) at the start of your terminal line. If you don't, it isn't activated.
Install the dependencies.
pip install -r requirements.txt
pip install ultralytics
The second one is for YOLOv8 vehicle detection. It's a big download, so give it a few minutes.
Set up the environment file.
# Windows
copy .env.example .env
# macOS / Linux
cp .env.example .env
You can leave TOMTOM_API_KEY and ORS_API_KEY empty. The app runs in simulated mode without them. Add an ORS key later if you want the route planner working.
Prepare the database and data, in this exact order.
python manage.py migrate
python manage.py seed_from_artifacts
python manage.py create_superuser_fixture
python manage.py run_predictions
python manage.py collectstatic --noinput
The seed command loads 16 Pune intersections and 35 days of traffic history. The predictions command then fills in tomorrow's forecast for every junction.
Start the server.
python manage.py runserver
Open http://localhost:8000 in your browser and log in with admin / admin123.
docker compose up --build
Then open http://localhost. Docker handles migrations, seeding and static files for you, but the artifacts folder still needs to be in place first.
BEST_classifier.pkl: your artifacts folder is in the wrong place, usually nested one level too deep like ml/artifacts/artifacts/models. Fix the path, then run python manage.py check_deploy to confirm.InsufficientHistoryError when running predictions: the model needs at least 21 days of history and the seed step didn't run. Run seed_from_artifacts again. It's safe to run twice.yolov8n.pt (about 6 MB) in the background. Pre-download it with python -c "from ultralytics import YOLO; YOLO('yolov8n.pt')".Set-ExecutionPolicy -Scope CurrentUser RemoteSigned once, then activate again./dashboard/ shows summary cards, a volume trend chart and a congestion doughnut./map/ shows 16 coloured markers across Pune. Click one and you'll see its prediction./vision/. You should get an annotated image with vehicle counts.python -m pytest tests/ -v. All 8 should pass.If all five check out, you're ready for your demo.
Our team is here to assist you with installation and setup.