There are several common forms of concrete cracks, including hairline cracks that typically appear in concrete foundations as the concrete dries, shrinkage cracks that arise when the concrete dries, and settlement cracks that occur as part of the concrete moves. When the earth beneath the slab is not compacted adequately, concrete might sink, and structural flaws can appear as a result of poor construction. If not quickly detected and corrected, concrete fractures can jeopardize a building's stability and safety. As such building a model which can accurately predict the cracks as they happen is crucial.
Transfer learning is used in the creation of this project to speed up the training phase by utilizing a pretrained model called the MobileNetV2.
The image dataset obtained from Çağlar Fırat Özgenel is loaded into the project and split between training and validation at a ratio of 80:20 using Keras.
A few images from the train dataset are displayed to make sure that the images are loaded properly.
Sample image of the data in the train dataset.
The validation dataset is split again into a validation and test dataset. All three datasets are then converted into Prefetch Dataset. An image augmentation layer is then defined with random flip, random rotation, and random zoom function. The image augmentation layer is then tested by applying it to an image and displaying the image after it had been augmented.
Image augmented by the image augmentation layer.
MobileNetV2 is used as the base model for the project. The preprocess input for the MobileNetV2 is used as the normalization layer precede by the image augmentation layer that was created in the previous step. A classifier with a GlobalAveragePooling2D, a Dropout layer, and a Dense layer is made to classify the output obtained from the base model. Three callback functions are used during the model training namely, TensorBoard, EarlyStopping, ReduceLROnPlateau, and ModelCheckpoint. The training process of the model is monitored through TensorBoard.
Accuracy changed during model training with the pink line as training and the green line as validation.
The model is evaluated with a classification report and the detailed results of the prediction made by the model are shown in the Results section below.
The model is saved into an h5 file to be loaded for deployment.
The classification report created with the prediction made by the model can be seen below. The model scored 96% and 97% in F1-score and 97% in accuracy.
Classification report for the prediction made by the model.
To run the python file, you need to download the dataset from here and extract it into a new folder named dataset in the project path.
The path of the dataset folder should be <PROJECT_PATH>/dataset/Concrete Crack Images for Classification/
A huge thanks to Çağlar Fırat Özgenel for sharing the dataset used for this project!
Thanks to the team who develop and publish the MobileNetV2 model used in this project.