Traffic congestion primarily occurs due to unknown factors such as bad weather conditions, unexpected vehicular failure or a road accident. So, a continuous evaluation of the road traffic needs to be done to determine the congestion free paths. Unlike traditional approaches for determining traffic flow (e.g., hose counts and manual counts) and conventional sensors used in road traffic monitoring (e.g., auto scope and loop detectors), cameras provide the best technology to acquire the data in real- time due to their higher sensing range. Cities usually shares their traffic data with the public so that citizens can be informed of what is happening in their city. Such information also helps officials make smart traffic management decisions, such as when to implement (1) traffic-calming measures, (2) walking and cycling improvements, (3) traffic and parking regulations, and (4) bus stop locations.
What it does
In this project, we designed and developed a camera-based traffic monitoring and prediction application that uses AI to automatically identify and track vehicles, bikes, and pedestrians. The application uses 124 traffic cameras deployed across the City of Calgary and provides near real-time information about vehicles, bikes, and pedestrians traffic flow. It also provides a historical overview that shows traffic volume in different communities across the city.
How we built it
Traffic Watch is built using free and open source software, open standards, and open data - YOLO, TensorFlow 2.0, NodeJS and Express, VueJS, Vuetify, and Mapbox GL JS are used to create the system components. It collects camera images from the City of Calgary’s open data website every 5 minutes, analyzes them using a machine learning models built by YOLO and TensorFlow 2.0, and displays results on a map. Figure below shows Traffic Watch's overall architecture.
The traffic forecasting model was trained on a local machine and the model was then deployed on Azure cloud infrastructure. The Azure Machine Learning SDK for Python was used to deploy the model as an Azure Container Instance. After deployment, the Azure ML exposed the model on the containers directly to the internet via a REST API endpoint. This endpoint is being consumed by the Traffic Watch's backend API to receive the real-time traffic pattern forecasting. The API sends the required payload to the deployed web service and receives the forecasted time series back for the requested camera. Details of the Azure ML deployment can be found here.
Accomplishments that we're proud of
We built a camera-based road traffic monitoring and prediction application that uses two deep neural network models (object-detection and time-series forecasting with embeddings). It provides convincingly good accuracy compared with existing approaches. Our approach is computationally light and robust, which can provide satisfactory results for variable illumination and weather conditions, thus making it suitable for using available traffic camera infrastructure with minimal cost for data-driven decision making.
What we learned
We observed that when network complexity increases, the algorithm accuracy will decrease, for example when using stacked LSTM layers in the model. With simpler NN architecture along with categorical embeddings feature inputs, we improved the accuracy and achieved better results.
What's next for Traffic Watch:
- Using NLP to extract incident reports from tweets and display them on the map.
- Improving object detection accuracy by fine tuning the model using custom image datasets.
- Traffic prediction: https://github.com/khordoo/traffic-watch-timeseries-prediction
- Object detection: https://github.com/khordoo/traffic-watch-object-detection
- Frontend: https://github.com/mepa1363/traffic-watch-frontend
- Backend service: https://github.com/mepa1363/traffic-watch-backend
For more information see https://docs.google.com/document/d/17QY3IbYpd0ch7tLU15C4kSH87WXsVLQV5nMmwq_70gs/edit?usp=sharing