structural-damage-detection

🧱 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:

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


🎯 Key Objectives


🧠 Why This Approach?

Why CNN (MobileNet)?

Why OpenCV + Image Processing?

Why Hybrid (ML + CV)?


🗂️ Datasets Used

1️⃣ Crack500 Dataset

Used for training the CNN model.

2️⃣ SDNET2018 Dataset

Used for realistic structure damage analysis.

📁 Dataset Structure (Required)

datasets/
├── train/
│   ├── Cracked/
│   └── Non-cracked/
├── val/
│   ├── Cracked/
│   └── Non-cracked/

⚠️ Only this structure works with ImageFolder in PyTorch.


🤖 Models Used

🔹 MobileNetV2 (PyTorch)

🔹 Grad‑CAM


🔬 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

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

Libraries Used


💻 Hardware Requirements


🌲 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

❌ Don’t


🚀 Future Improvements


🏁 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.