Skip to content
← Projects

Project

Concrete Crack Detection with Grad-CAM

Part of Vveer Motani's portfolio · Robotics & Physical AISee everything →

A fine-tuned ResNet-18 that classifies concrete surfaces as cracked or intact, with Grad-CAM maps that show which pixels each decision was based on.

shipped#computer vision#explainability#structural inspection
Val accuracy
99.51%
Model
ResNet-18
Images
40,000
Epochs
3

Built withPythonPyTorchOpenCV

Original Grad-CAM Prediction
Concrete surface with a crack Grad-CAM heatmap concentrated on the crack Crack
Concrete surface with a crack Grad-CAM heatmap concentrated on the crack Crack
Intact concrete surface Grad-CAM heatmap with no focused region No crack

Red marks the regions that most influenced the prediction; blue marks regions the model ignored.

Why Grad-CAM

Training the classifier is the easy part. The harder question is whether it detects cracks or just correlates with something else in the image, such as lighting, texture or background. Grad-CAM answers that by showing which pixels the decision depended on. If the red sits on the crack, the model learned the right thing.

How it works

  • Transfer learning. All convolutional layers of a pretrained ResNet-18 are frozen, and only a new head (nn.Linear(512, 2)) is trained. The pretrained layers already encode edges, textures and discontinuities; the head learns what to look for.
  • Grad-CAM. Two hooks on the last convolutional block (layer4[-1], 512 maps at 7×7) capture its activations on the forward pass and the gradients of the predicted class on the backward pass. Each map is weighted by its mean gradient, and the weighted sum becomes the heatmap.

Results

99.51% validation accuracy after 3 epochs on the surface crack dataset (Özgenel and Gönenç Sorguç, ISARC 2018): 40,000 images at 227×227, half cracked and half intact. The dataset is balanced and the crops are clean, so the accuracy says less than the heatmaps do about whether the model would hold up on real inspection images.

Next

Severity classes (hairline, moderate, severe), then running the pipeline on sequential frames from site inspection surveys.