This project improves on the already existing preset traffic light timers by dynamically predicting time based on the number of vehicles available.
We built this system during Smart India Hackathon 2024 as a team of 6. It's a work-in-progress solution that leverages AI to take over the role of traffic police operators who manually press buttons inside booths to change signals during peak hours (yes, this still happens).
Instead of static light timers or maunal buttons, this system detects vehicle density from existing CCTV feeds and intelligently adjusts traffic signal durations. No additional infrastructure is needed — just plug in the model and let it watch.
It’s smarter, faster, fairer, and doesn’t need breaks.
A frame is captured from each camera and passed to an EfficientDet-Lite3 model. It identifies and counts vehicles across six classes: car, bike, rickshaw, cart, truck, ambulance. EfficientDet was chosen over YOLO because it handled occlusions and stacked vehicles more accurately — something critical for tight Indian intersections.
EfficientDet builds on EfficientNet with compound scaling and BiFPN — which makes it surprisingly performant on edge devices or cloud VMs. We’ve run it smoothly even on lower-powered hardware.
The number of vehicles is then used to estimate a signal time using a Decision Tree Regressor. If at least one vehicle is detected, a minimum time of 15 seconds is assigned; if zero, the signal is skipped. Everything rotates in a round-robin loop with configurable maximums (60 or 120s).
To go one step further, we use an LSTM model to refine predictions based on the time of day and historical traffic data collected manually from real signals in our area. It helps capture rush hour patterns that repeat daily and weekly.
This cascading logic ensures that each intersection gets time proportionally, based on how busy it actually is.
This project is what happens when you say “how hard could traffic lights be?” and then lose three weeks to annotation, debugging loss shapes, and writing a collate function that doesn’t crash PyTorch.
We had to manually annotate a custom dataset(shocking) in Pascal VOC, then convert it to COCO and TFRecord (because why pick one format when you can juggle three?). We trained EfficientDet with Focal Loss, which was fun until cross-entropy started throwing dimension mismatches. Oh, and we wrote our own logic to trim prediction boxes and filter out garbage detections.
The collate function alone — pain. Eventually, it worked. Mostly.
For LSTM training, we collected data from real junctions by literally standing there, noting traffic counts by hand(fr, had to note down in my phone using my bare hands). In the heat. During traffic. True field work fr fr ong no cap. (Traffic police have it hard having to do this all day)
Above: Live detection output. Vehicles boxed and counted(boxes are uhh, just a little offset to the top-left). Signal durations predicted automatically.
Comments