File size: 1,206 Bytes
4a0ea4c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
---
license: mit
library_name: pytorch
pipeline_tag: image-classification
tags:
  - thermal-imaging
  - anomaly-detection
  - resnet
  - lstm
  - pytorch
---

# Thermal Pattern Analysis — CNN + Bi-LSTM

Anomaly detection model for infrared thermal images of power transformers.

## Architecture

3-stage pipeline:
1. **Feature Extraction** — Modified ResNet-18 (grayscale input, 256-dim embeddings)
2. **Temporal Analysis** — Bidirectional LSTM + Self-Attention (128 hidden, 2 layers)
3. **Anomaly Detection** — Cosine similarity scorer (threshold: 0.7)

## Usage

```python
import torch
from huggingface_hub import hf_hub_download

ckpt_path = hf_hub_download("Zorrojurro/thermal-pattern-analysis", "best_model.pt")
ckpt = torch.load(ckpt_path, map_location="cpu", weights_only=False)
# model.load_state_dict(ckpt["model_state_dict"])
# classifier.load_state_dict(ckpt["classifier_state_dict"])
```

## Demo

Live demo: [Zorrojurro/thermal-backend](https://huggingface.co/spaces/Zorrojurro/thermal-backend)

## Training

- Dataset: SciDB Infrared Thermal Image Dataset (895 IR images)
- Optimizer: AdamW (lr: 3e-4)
- Epochs: 100 with early stopping (patience: 25)
- Image size: 224×224 grayscale