Coders Packet

Crack detection by CNN using Keras in Python

By Saurabh Damle

This project is a demonstration of building a CNN in Python to detect if cracks are present in the image. It uses Keras framework.

In this project we will build a Convolutional Neural Network which will be able to detect whether there are cracks present in the image or not.The project will help in maintenance of huge buildings where a drone can capture images and this model will help in determining cracks.

This project is written in Python and uses the following libraries and frameworks:

1. Keras

2. Matplotlib

3. NumPy


The steps followed in the project are:

1. Exploring the dataset

2. Data visualization

3. Processing the dataset

4. Building the data pipeline for the model

5. Using keras to build the model and training

6. Model evaluation and tuning.



We will first import all the required libraries.

Then we wil look at the dataset. This dataset is in the form of images with positive images(with cracks) in one folder and negative images(without cracks) in another folder.

We will be using Keras's image data preprocessing to build the dataset from the directory and scale the images.

The next step will be be building the data generator which will generate the batches for training.

Next we will build the model: It consists of following layers:

1. Conv2d  2. Max-pooling layer 3. Dense layers(128, 64, 32, 1)

The optimizer that we will be using is RMS with learning rate of 0.001 and loss function will be Binary cross entropy

Then we will train the model for 10 epochs with 100 steps per epoch.


At the end of the project, the model will be able to classify cracks.

Download Complete Code


No comments yet