Hashwanth Gogineni's other Models Reports

Major Concepts

 

Sign-Up/Login to access Several ML Models and also Deploy & Monetize your own ML solutions for free

Models Home » Generic Models » Road Pothole Detection

Road Pothole Detection

Models Status

Model Overview

Potholes


'Potholes' form as a result of a combination of scientific processes at the action. Driving on a newly surfaced road is a lot of joy. But, after time, all that traffic takes its toll. Consider the toll that millions of tires travelling at high speeds have on the typical roadway.


The friction between tires and road surface warms up and causes the road to expand. This expansion might result in the creation of fissures in the pavement surface over time. This allows water to leak into the cracks.


The freeze-thaw cycle, especially in cooler temperatures, may quickly convert those little fissures into potholes. For example, when water penetrates deep into highway cracks from rain or snow, it can freeze when temperatures drop at night. When water freezes, it eventually expands and pushes against the fissures' borders. Likewise, it can press upon the pavement from below if it has leaked beneath the top layer of pavement.


The water melts when the temperature rises, producing wider cracks—often referred to as divots—all over the road surface. Divots that grow beneath the top layer of pavement can swiftly turn into potholes. When cars travel over the pavement with a divot beneath it, the vehicle's weight can force the top layer of pavement into the divot's area. This results in a pothole on the road surface.




Why Pothole Detection Project?


The project can help government road safety organizations to detect potholes on the road and take necessary measures to repair the road as soon as possible.


 


Dataset


These images are downloaded from google images search results and scrapped using the "googleimagesdownload" library.


The dataset includes two labels containing 1000 images each, i.e., "Normal" and "Pothole." Thus, there are a total of 2000 images in the dataset, which includes plain roads and damaged roads.





ResNet


ResNet is an abbreviation for Residual Network. Their 2015 computer vision research article titled 'Deep Residual Learning for Image Recognition,' Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun proposed a unique neural network.


This model was quite successful, as evidenced by its ensemble taking first place in the ILSVRC 2015 classification competition with a 3.57 per cent error rate. It also won first place in the ILSVRC and COCO contests in 2015 for ImageNet detection, ImageNet localization, COCO detection, and COCO segmentation.


ResNet comes in various flavours, each with a different number of layers but the same basic premise. For example, Resnet50 refers to a variation that can function with up to 50 neural network layers. ResNet was built specifically to address this issue. Residual blocks are used in deep residual nets to increase model accuracy. The strength of this form of the neural network is the idea of "skip connections," which is at the heart of the residual blocks.



Understanding Code:

First, let us import the required libraries for our project.


import numpy as np 
import pandas as pd
import os
import tensorflow as tf
from keras.preprocessing.image import ImageDataGenerator
import cv2
import matplotlib.pyplot as plt
from tensorflow.keras.layers import Dense, Flatten, Conv2D, MaxPooling2D, Dropout, Activation
from keras.models import Sequential
from tensorflow.keras.applications.resnet50 import ResNet50
from tensorflow.keras.applications.resnet50 import preprocess_input
from keras.models import Model
from tensorflow.keras.optimizers import Adam


Now, let us load the data into our system.


train_datagen = ImageDataGenerator(preprocessing_function=preprocess_input, validation_split=0.20)

training_set = train_datagen.flow_from_directory('/content/sample_data/data/train',
target_size = (256, 256),
batch_size = 64,
class_mode = 'categorical',
color_mode="rgb",
subset="training")

validation_generator = train_datagen.flow_from_directory(
"/content/sample_data/data/train",
target_size=(256, 256),
batch_size=64,
class_mode='categorical',
color_mode="rgb",
subset='validation',
shuffle = False)

Also, I used the 'flow_from_directory' function to load the images from a directory.
As you can see, I used the "ImageDataGenerator" function for data augmentation purposes.
I also preprocessed the inputs to help the model train better.

Next, let us dive into the modelling section of our use case.


base_model=ResNet50(include_top=False, weights='imagenet',input_shape=(256,256,3), pooling='max')
base_model.summary()

So, I chose the 'ResNet50' model to get the best out of our data.
I used 'imagenet' as weights for our model.


model=Sequential()
model.add(base_model)
model.add(Dropout(0.20))
model.add(Dense(2048,activation='relu'))
model.add(Dense(1024,activation='relu'))
model.add(Dense(512,activation='relu'))
model.add(Dense(2,activation='sigmoid'))

I also used neural network layers to the model for efficient results.

As our model is ready, let us now compile our model. 


epochs=25
batch_size=128

base_model.trainable=True # setting the VGG model to be trainable.
model.compile(optimizer=Adam(lr=1e-5),loss='categorical_crossentropy',metrics=['accuracy'])
callback = tf.keras.callbacks.EarlyStopping(monitor='accuracy', patience=2)
model.summary()


Now let us fit our data into our model.


history=model.fit_generator(training_set,
validation_data=validation_generator,
epochs=15,
callbacks=callback)


Finally, let us have a look at our model's performance report.


# Classification Report

from sklearn.metrics import classification_report
test_labels=test_generator.classes
predictions=model.predict_generator(test_generator, verbose=1)
y_pred = np.argmax(predictions, axis=-1)
print(classification_report(test_labels, y_pred))


Here '0' represents 'Normal road' and '1' represents 'Pothole road' in the classification report. 

As you can see, our model performed well considering the report.



Thank you for your time.









0 comments