Skip to content

KuldeepSingh-18/structural-damage-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧱 Early Detection of Structural Damage Using Deep Learning & Computer Vision

πŸ“Œ Project Overview

This project focuses on early detection of structural damage (cracks, spalling, collapse risk) in walls and concrete structures using a combination of Deep Learning (MobileNet CNN) and Computer Vision (OpenCV + image processing) techniques.

The system provides:

  • Crack / Non‑crack classification
  • Damage severity analysis
  • Crack visualization (minor & major cracks)
  • Training performance metrics (loss & accuracy)
  • Interactive Streamlit web application with upload & camera support

This project is suitable for academic projects, research prototypes, and real‑world inspection assistance systems.


🎯 Key Objectives

  • Detect cracks and damage in wall/structure images
  • Ignore irrelevant objects (people, windows, background clutter)
  • Highlight minor cracks (green) and major cracks (red)
  • Provide interpretable metrics (edge density, texture variance, confidence)
  • Visualize model training performance

🧠 Why This Approach?

Why CNN (MobileNet)?

  • Lightweight and fast
  • Works well on limited hardware
  • Pretrained on ImageNet β†’ strong feature extraction
  • Suitable for real‑time and deployment

Why OpenCV + Image Processing?

  • Crack geometry is thin and irregular β†’ classical CV works well
  • Edge detection & skeletonization help localize cracks
  • Enhances explainability beyond black‑box ML

Why Hybrid (ML + CV)?

  • CNN β†’ classification (cracked / non‑cracked)
  • OpenCV β†’ localization & severity analysis
  • Produces both decision + visualization

πŸ—‚οΈ Datasets Used

1️⃣ Crack500 Dataset

Used for training the CNN model.

  • Contains cropped crack images
  • High‑quality labeled crack patterns

2️⃣ SDNET2018 Dataset

Used for realistic structure damage analysis.

  • Categories:

    • Walls
    • Pavements
    • Decks
  • Each with:

    • Cracked
    • Non‑cracked

πŸ“ Dataset Structure (Required)

datasets/
β”œβ”€β”€ train/
β”‚   β”œβ”€β”€ Cracked/
β”‚   └── Non-cracked/
β”œβ”€β”€ val/
β”‚   β”œβ”€β”€ Cracked/
β”‚   └── Non-cracked/

⚠️ Only this structure works with ImageFolder in PyTorch.


πŸ€– Models Used

πŸ”Ή MobileNetV2 (PyTorch)

  • Pretrained weights: ImageNet
  • Modified classifier layer for binary classification
  • Saved model: mobilenet_crack.pth

πŸ”Ή Grad‑CAM

  • Used for visual explanation of CNN focus regions

πŸ”¬ Training Process

Steps:

  1. Load dataset using ImageFolder

  2. Apply data augmentation

  3. Load pretrained MobileNetV2

  4. Replace classifier head

  5. Train using CrossEntropyLoss

  6. Track loss & accuracy per epoch

  7. Save:

    • Model weights
    • Training loss graph
    • Training accuracy graph

Output:

outputs/
β”œβ”€β”€ loss.png
β”œβ”€β”€ accuracy.png

πŸ–ΌοΈ Image Analysis Process (Inference)

  1. Image upload / camera capture

  2. Object filtering (ignore people/windows)

  3. CNN prediction:

    • Cracked / Non‑cracked
    • Confidence score
  4. OpenCV analysis:

    • Edge density
    • Texture variance (GLCM)
    • Damage severity
  5. Crack highlighting:

    • Minor cracks β†’ Green
    • Major crack β†’ Red (longest skeleton path)

🌐 Streamlit Web Application

Features

  • Upload image
  • Camera capture
  • Training metrics display (front page)
  • Real‑time crack analysis
  • Highlighted crack visualization

Main File

app.py

▢️ How to Run the Project

1️⃣ Clone / Open Project

cd "project c"

2️⃣ Create Virtual Environment

python -m venv venv
.\venv\Scripts\activate

3️⃣ Install Dependencies

pip install -r requirements.txt

4️⃣ Train Model (Optional)

python train.py

5️⃣ Run Web App

streamlit run app.py

🧾 Software Requirements

  • Windows / Linux
  • Python 3.9+
  • VS Code (recommended)
  • Streamlit

Libraries Used

  • torch, torchvision
  • opencv‑python
  • numpy
  • matplotlib
  • scikit‑image
  • streamlit
  • pillow

πŸ’» Hardware Requirements

  • Minimum:

    • CPU i5 / Ryzen 5
    • 8 GB RAM
  • Recommended:

    • GPU (CUDA supported)
    • 16 GB RAM

🌲 Project Structure

project c/
β”œβ”€β”€ app.py
β”œβ”€β”€ train.py
β”œβ”€β”€ evaluate.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ README.md
β”œβ”€β”€ datasets/
β”‚   β”œβ”€β”€ crack500/
β”‚   └── sdnet/
β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ mobilenet_model.py
β”‚   └── gradcam.py
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ classifier.py
β”‚   β”œβ”€β”€ cv_analysis.py
β”‚   β”œβ”€β”€ image_utils.py
β”‚   └── object_filter.py
β”œβ”€β”€ outputs/
β”‚   β”œβ”€β”€ loss.png
β”‚   └── accuracy.png
└── venv/

⚠️ Things to Keep in Mind

βœ… Do

  • Activate venv before running
  • Maintain dataset folder structure
  • Run train.py before first inference
  • Use clear wall/structure images

❌ Don’t

  • Rename dataset folders randomly
  • Mix cracked & non‑cracked images
  • Delete outputs/ after training
  • Upload unrelated images (people, objects)

πŸš€ Future Improvements

  • Add YOLO‑based object filtering
  • Multi‑class damage classification
  • Crack width & length measurement
  • Video / live camera stream analysis
  • Cloud deployment
  • Automated report generation (PDF)
  • Improved major crack confidence scoring

🏁 Conclusion

This project demonstrates a practical, explainable, and deployable approach for structural damage detection using modern AI and classical vision techniques. It balances accuracy, performance, and interpretability, making it suitable for real‑world inspection systems.


πŸ“Œ Developed as an academic and research‑oriented structural inspection system.

Releases

No releases published

Packages

 
 
 

Contributors

Languages