Projects/Three-Class Building Damage Classifier
Three-Class Building Damage Classifier

Three-Class Building Damage Classifier

Drone-image classifier for undamaged / damaged / collapsed buildings, comparing 12 model variants and a Grad-CAM-guided crop pipeline.

PythonPyTorchYOLOv8Grad-CAMNumPyPandasscikit-learn

About this project

Pattern Recognition final project. The dataset combines drone images from the 2023 Turkey earthquake (UAV-TEBDE / Mendeley + Kaggle) and a Yushu, China research set into 9.6k train / 1.7k val / 4.7k test images across three classes. Both YOLOv8n-cls and YOLOv11n-cls were trained at three center-crop sizes (100 / 90 / 80%), softmax probabilities of each pair were averaged into soft-voting ensembles, and a Grad-CAM-guided crop dataset was generated from the best individual model (YOLOv8 @ 80%, highest macro-F1) and used to retrain both architectures. Because the test set is heavily class-imbalanced (damaged 2820, collapsed 1140, undamaged 802), macro-F1 — not accuracy — was the primary metric throughout.

  • 12 model variants: 2 architectures × 3 crop sizes × (single + ensemble + CAM-crop)
  • Grad-CAM-guided crop pipeline — threshold 0.4, 0.15 padding, fallback on empty mask
  • Soft-voting probability averaging with alphabetical→canonical class index remapping
  • MD5 deduplication + train/test leakage verification before training

Key features

Two YOLOs

v8n-cls + v11n-cls fine-tuned

Soft-vote ensemble

Probability averaging

Grad-CAM crop

Attention-guided dataset rebuild

Class-imbalanced

Macro-F1 over accuracy


Screenshots

Confusion matrices across center-crop models

Grad-CAM comparison on collapsed class

Accuracy vs macro-F1 across all variants

Per-class error rate heatmap


Tech stack

Python
PyTorch
YOLOv8
Grad-CAM
NumPy
Pandas
scikit-learn

Other projects