traffic congestion prediction with images
TRANSCRIPT
Traffic Congestion Prediction
Based on Image processing
Overview• Objective• Packages used• Processing the images• Building the model• Testing the model• Challenges
Objective• Based on a image taken of the road with cars, we want to build a
machine learning model to predict the state of congestion.
Packages Used• Scikit-image• Scikit-learn• Matplotlib
Processing the images• Image of road conditions are obtained from
http://www.mytransport.sg/content/mytransport/home/dataMall.html• LTA Datamall provides access to the Traffic Camera images refreshed
every 5 minutes• Cronjob to download an image every 5 minutes.
Get the images using GET requests
Save it as a jpg by writing blocks
Sample code
Processing the images• Using Scikit-image, we used the Histogram Oriented Gradients algorithm to generate the features of each image.
See more about HOG here:
https://en.wikipedia.org/wiki/Histogram_of_oriented_gradients
• Unfortunately, we had to manually label each image of the road condition : 1 (no congestion), 2(somewhat congested), 3(congested)
Processing the images• We generated the features based on traffic images over 7 days.• The images need to be converted to Gray-scale prior to applying the
HOG algorithmSample code
Processing the images• What did HOG do?• Each image generated 9,600 features
Building the model• So now we have our features we can build our model• Using RandomForest with 20 estimators
Sample code
Testing the model
Example:Accuracy: 0.929054054054Low/No Congestion [[776 1 0]Medium Congestion [ 52 21 0]High Congestion [ 8 2 28]]
We obtained some interesting results depending on the images and which road was used.
Sample code
Challenges• Labelling the images• Image resolution – maybe implementing some filters might help to
improve• Time of day – at night lights from the cars were creating big white
blobs. In a way it did not really matter as a white blob just meant that there was some cars there and a congestion might be occurring.• Some images downloaded were corrupted