Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
library_name: pytorch
|
| 4 |
+
pipeline_tag: image-classification
|
| 5 |
+
tags:
|
| 6 |
+
- thermal-imaging
|
| 7 |
+
- anomaly-detection
|
| 8 |
+
- resnet
|
| 9 |
+
- lstm
|
| 10 |
+
- pytorch
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# Thermal Pattern Analysis — CNN + Bi-LSTM
|
| 14 |
+
|
| 15 |
+
Anomaly detection model for infrared thermal images of power transformers.
|
| 16 |
+
|
| 17 |
+
## Architecture
|
| 18 |
+
|
| 19 |
+
3-stage pipeline:
|
| 20 |
+
1. **Feature Extraction** — Modified ResNet-18 (grayscale input, 256-dim embeddings)
|
| 21 |
+
2. **Temporal Analysis** — Bidirectional LSTM + Self-Attention (128 hidden, 2 layers)
|
| 22 |
+
3. **Anomaly Detection** — Cosine similarity scorer (threshold: 0.7)
|
| 23 |
+
|
| 24 |
+
## Usage
|
| 25 |
+
|
| 26 |
+
```python
|
| 27 |
+
import torch
|
| 28 |
+
from huggingface_hub import hf_hub_download
|
| 29 |
+
|
| 30 |
+
ckpt_path = hf_hub_download("Zorrojurro/thermal-pattern-analysis", "best_model.pt")
|
| 31 |
+
ckpt = torch.load(ckpt_path, map_location="cpu", weights_only=False)
|
| 32 |
+
# model.load_state_dict(ckpt["model_state_dict"])
|
| 33 |
+
# classifier.load_state_dict(ckpt["classifier_state_dict"])
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
## Demo
|
| 37 |
+
|
| 38 |
+
Live demo: [Zorrojurro/thermal-backend](https://huggingface.co/spaces/Zorrojurro/thermal-backend)
|
| 39 |
+
|
| 40 |
+
## Training
|
| 41 |
+
|
| 42 |
+
- Dataset: SciDB Infrared Thermal Image Dataset (895 IR images)
|
| 43 |
+
- Optimizer: AdamW (lr: 3e-4)
|
| 44 |
+
- Epochs: 100 with early stopping (patience: 25)
|
| 45 |
+
- Image size: 224×224 grayscale
|