Pothole Detection using an Android Application

Abstract

Poor road conditions are causing a lot of discomfort to people, leading to vehicles damage and loss of precious lives. Moreover, potholes lead to the D-shaping of tyre, making them weak and in need of replacement sooner rather than later. It usually costs 4500-12500 pkr/tyre which is not so affordable for everyone. Not changing the weak tyre can cause tyre burst. Potholes also cause a great damage to the car’s suspension, bolts and shocks, causing them to be changed once in every six months, which is also not so affordable. One of the accidents happened outside CUI, Lahore campus, a few students, driving a car at  high speed got panicked when they saw a pothole very close, couldn’t control the speed leading to an accident with serious injuries. Keeping in mind all these problems, our final year project aims to develop such an android application which will detect the potholes and pin the potholes’ current location on the map which will be updated to the server side. The application will use city map and current location of the driver as they turn on their phone’s GPS. 

How the detection is done?

Detection of potholes will be done using two techniques as proposed in the application. First technique is using image processing, as the driver drives through the road with a window mounted phone camera. We will train our model to detect the potholes using Mobile Net SSD v2 quantized coco and then our application will pin the current location on the map indicating a pothole. The second technique is by using the gyroscope and accelerometer sensors in the phone. As the driver drives the car through the city, we will train our model using SVM classifying technique to detect the potholes and pin the location on the map. The user can decide if he wants to use the phone’s camera or the phone’s sensor or both. 

Challenges we faced.

Choosing the model for training the vision-based detection was really tough.

The first choice was YOLO v2 as its faster than other networks like CNN, Fast RCNN, Faster RCNN, etc.

An open-source pre-trained pothole detection YOLO model was found from an internet resource, the pre-trained model, however, had many errors. Debugging was very time consuming, but it was then able to do predictions. 

However, the model was now able to do predictions but the results, but the accuracy was 61%, so the model had to be retrained using our dataset containing the 953 images. As a result, the accuracy was improved.

The retrained YOLO v2 predicted very well, but issues came when trying to convert the TensorFlow model to the TensorFlow Lite model. Also, a lot of memory was needed to store the tflite model on the mobile phone.

Mobile Net SSD v2 quantized coco is specially designed for mobile applications and Google coral devices. The dataset we used contained 260 images with 321 pothole labels.

Training of Mobile Net SSD v2 quantized coco was done on a custom-built Computer using NVIDIA GTX 1070 with 8GB VRAM with 1920 CUDA cores. The training took 6 days with 134887 number of iterations. No more iterations took place as the loss was constant.

To use the Deep Learning model for pothole detection we used an open source TensorFlow pre trained model that was trained with the YoloV2 architecture to detect the potholes. The model was predicting well but problem occurred while integrating it to the android application. A model trained on YoloV2 cannot be converted easily to TensorFlow lite format as some layers of this model doesn’t support TensorFlow lite.

For deploying a machine/deep learning model to android phone the TensorFlow provide TensorFlow lite format for the machine/deep learning model. TensorFlow lite model is then used in android for inferencing.

For using a machine learning model in an android device, the TensorFlow recommends to use their pre trained ssd models like mobilenet and its quantized version.

Our dataset was collected from streets of Lahore like college road, Valencia road etc. After labeling the images training was started on ssd mobilenet v2 quantized version model. After the training we got excellent results from our model. 

Now it was the time to convert that model to TensorFlow lite format, it wasn’t the easy task as we have to build TensorFlow from source and had to create separate environment for converting a TensorFlow model to TensorFlow lite format.

After the training process we exported the TFlite graph (.pb and .pbtxt) using the last saved training checkpoint because for converting a TensorFlow model to TensorFlow lite format you have to export a tflite graph of that trained model. The tflite graph had to run through the TensorFlow lite Optimizing Converter i.e. TOCO as it helps us to convert our tflite graph to .tflite format and for using TOCO we have to build TensorFlow from source. 

While converting the TensorFlow model to TensorFlow lite format we had to resolve many dependencies.  For more information on converting TensorFlow to TensorFlow lite you can go through this link:

github.com/EdjeElectronics/TensorFlow-Lite-Object-Detection-on-Android-and-Raspberry-Pi#step-1-train-quantized-ssd-mobilenet-model-and-export-frozen-tensorflow-lite-graph

It was difficult to choose between Support Vector Machine (SVM) classifier and the Logistic Regression (LR). However, after testing both the algorithms SVM proved to give better accuracy 0.63 whereas LR gave 0.55 accuracy.

Android Application & the Server-end looks like:

Application Test Results:

Training results:

The results of Mobile Net SSD v2 quantized coco is on the left.

Tensorboard Results:

The figure below shows the comparison between how the bounding boxes of the potholes are made the Label Img tool (right side) and by the model (left side).

The accuracy of SVM (Support Vector Machine) classifier:

The above figure shows the overall accuracy of the SVM classifier which is 0.63

Confusion Matrix and Pothole versus smooth road precision, recall, f1-score, support:

The above figure shows Confusion Matrix and Pothole versus smooth road precision, recall, f1-score, support of SVM classifier. Here, target 0 is smooth road and target 1 is potholes on the road. The precision of the smooth road is 0.50, whereas, that of the pothole is 0.71, the recall for smooth and potholes is 0.49 and 0.72

During Final Presentation:

Presentation:

FYP-Pothole detection_presentation.pptx

Supervisor

HEC Approved PhD Supervisor,

Assistant Professor & Associate Head of Department

Department of Computer Science,

COMSATS University Islamabad, Lahore Campus, Pakistan

Group Members

Hamza Tanveer

Bachelors in Computer Science

Comsats University, Lahore Campus

www.linkedin.com/in/hamza-tanveer-31a42b122/

Laiba Ikram

Bachelors in Computer Science

Comsats University, Lahore Campus

www.linkedin.com/in/laiba-ikram-0138b2195/