Most traffic signals run on fixed timers. They have no idea how many cars are actually waiting. I wanted to build something that sees the road and actually thinks.
This is a three-stage AI pipeline for adaptive traffic signal control, built around a 30-junction Indian city simulation modeled on Jaipur's road network.
Stage 1 is a CNN that takes raw camera frames and outputs spatial density maps. It uses depthwise-separable grouped residual blocks to stay fast enough for edge deployment, and treats vehicle counting as a density regression problem, the same approach used in crowd counting research.
Stage 2 is an ST3DNet that forecasts future traffic density at 15-minute, 30-minute, and 1-hour horizons. It runs two parallel 3D convolutional streams, one over recent history and one over the same time window from prior weeks, then fuses them with learned per-pixel attention weights.
Stage 3 is where it gets interesting. I built a hierarchical Graph Neural Network with four levels. At the bottom, a patch CNN with cross-approach attention encodes each incoming lane. At the junction level, Set Attention Blocks aggregate all approaches. At the network level, a Graph Transformer propagates context across all 30 junctions simultaneously, with a temporal cross-attention window over the last 8 steps. The actor outputs both a discrete phase selection and a continuous green duration via a Gaussian head. Training uses MAPPO with a reward curriculum that starts purely on throughput, then gradually penalizes uneven queues and spillback.
I also built a VirtualCamera projection module that converts SUMO vehicle coordinates into synthetic density maps, bridging the gap between simulation and real camera input without needing labeled real-world data.