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.
- 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
- Lightweight and fast
- Works well on limited hardware
- Pretrained on ImageNet β strong feature extraction
- Suitable for realβtime and deployment
- Crack geometry is thin and irregular β classical CV works well
- Edge detection & skeletonization help localize cracks
- Enhances explainability beyond blackβbox ML
- CNN β classification (cracked / nonβcracked)
- OpenCV β localization & severity analysis
- Produces both decision + visualization
Used for training the CNN model.
- Contains cropped crack images
- Highβquality labeled crack patterns
Used for realistic structure damage analysis.
-
Categories:
- Walls
- Pavements
- Decks
-
Each with:
- Cracked
- Nonβcracked
datasets/
βββ train/
β βββ Cracked/
β βββ Non-cracked/
βββ val/
β βββ Cracked/
β βββ Non-cracked/
ImageFolder in PyTorch.
- Pretrained weights: ImageNet
- Modified classifier layer for binary classification
- Saved model:
mobilenet_crack.pth
- Used for visual explanation of CNN focus regions
-
Load dataset using
ImageFolder -
Apply data augmentation
-
Load pretrained MobileNetV2
-
Replace classifier head
-
Train using CrossEntropyLoss
-
Track loss & accuracy per epoch
-
Save:
- Model weights
- Training loss graph
- Training accuracy graph
outputs/
βββ loss.png
βββ accuracy.png
-
Image upload / camera capture
-
Object filtering (ignore people/windows)
-
CNN prediction:
- Cracked / Nonβcracked
- Confidence score
-
OpenCV analysis:
- Edge density
- Texture variance (GLCM)
- Damage severity
-
Crack highlighting:
- Minor cracks β Green
- Major crack β Red (longest skeleton path)
- Upload image
- Camera capture
- Training metrics display (front page)
- Realβtime crack analysis
- Highlighted crack visualization
app.py
cd "project c"python -m venv venv
.\venv\Scripts\activatepip install -r requirements.txtpython train.pystreamlit run app.py- Windows / Linux
- Python 3.9+
- VS Code (recommended)
- Streamlit
- torch, torchvision
- opencvβpython
- numpy
- matplotlib
- scikitβimage
- streamlit
- pillow
-
Minimum:
- CPU i5 / Ryzen 5
- 8 GB RAM
-
Recommended:
- GPU (CUDA supported)
- 16 GB RAM
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/
- Activate venv before running
- Maintain dataset folder structure
- Run
train.pybefore first inference - Use clear wall/structure images
- Rename dataset folders randomly
- Mix cracked & nonβcracked images
- Delete
outputs/after training - Upload unrelated images (people, objects)
- 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
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.