Skip to content

AI that utilizes Variational Autoencoders to identify defects in concrete infrastructure.

License

Notifications You must be signed in to change notification settings

PratikNichite/Anomaly-Detection-for-Infrastructure-Monitoring

Repository files navigation

🔍 Anomaly Detection for Infrastructure Monitoring

Python PyTorch OpenCV

Open in Colab License: MIT


🚀 Project Highlights

🔥 96.1% F1-score in detecting concrete cracks without labeled training data
🧠 Variational Autoencoder learns healthy infrastructure patterns
Training Pipeline - Complete notebook for model training
📊 Complete Analysis - From data preprocessing to deployment


💡 The Challenge

Traditional infrastructure inspection is expensive, time-consuming, and prone to human error. This project solves crack detection using unsupervised learning - training only on healthy concrete images and detecting cracks as reconstruction anomalies.

🎯 The Solution

Training Phase

graph LR
    A[Healthy Images Only] --> B[VAE Learning] --> C[Normal Patterns] --> D[💾 Model]
Loading

Inference Phase

graph LR
    E[Test Image] --> F[Reconstruct] --> G[Compare Error] --> H{High Error?}
    H -->|Yes| I[🚨 ANOMALY]
    H -->|No| J[✅ NORMAL]
Loading

📈 Results That Matter

📊 Metric 🎯 Score 📝 Impact
AUC 99.3% Industry-grade performance
Precision 97.8% Minimal false alarms
Recall 94.5% Catches nearly all cracks
F1-Score 96.1% Balanced detection

📊 Reconstruction Error Analysis

Reconstruction Error Distribution

Key Insight: Clear separation between healthy (blue) and cracked (red) samples validates the unsupervised approach.

🎨 Test Reconstruction Visualizations

Test Samples

Visualization of test sample reconstructions.


🚀 Quick Start

1️⃣ Train Your Model

git clone https://github.com/PratikNichite/Anomaly-Detection-for-Infrastructure-Monitoring.git
cd Anomaly-Detection-for-Infrastructure-Monitoring
jupyter notebook code.ipynb  # 👈 Train model from scratch

2️⃣ Use Trained Model

import torch
model = VAE()
model.load_state_dict(torch.load('best_vae.pth'))  # After training

# Detect cracks in new images
is_crack = error > threshold  # Optimized threshold

3️⃣ Dependencies

pip install torch torchvision opencv-python matplotlib seaborn jupyter

🏗️ Technical Architecture

Encoder[256×256×3] → [128×128×32] → [64×64×64] → [32×32×128] → [Latent: 128]

Decoder[Latent: 128] → [32×32×128] → [64×64×64] → [128×128×32] → [256×256×3]

🎯 Why VAE?

  • Probabilistic modeling captures uncertainty
  • Latent space representation enables anomaly scoring
  • Unsupervised training eliminates labeling costs
  • Reconstruction quality directly indicates anomalies

📁 Project Structure

📦 Anomaly-Detection-for-Infrastructure-Monitoring
├── 📔 code.ipynb           # 🌟 MAIN NOTEBOOK - Complete analysis
├── 🤖 best_vae.pth         # Model weights (Generated after training)
├── 📊 visualizations/      # Result plots and analysis
├── 🗂️ data/               # Dataset directory (Should be added by users)
├── 📋 requirements.txt     # Python dependencies
└── 📄 documentation.pdf   # Technical documentation

🎯 Key Achievements

Unsupervised Learning Success - No manual crack labeling required
High Performance - 96%+ F1-score on real infrastructure data
Production Ready - Optimized model with deployment pipeline
Comprehensive Analysis - End-to-end ML workflow demonstrated
Scalable Solution - Can process thousands of images efficiently


License

This project is licensed under the MIT License - see the LICENSE file for details.


About

AI that utilizes Variational Autoencoders to identify defects in concrete infrastructure.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published