rmxjck commited on
Commit
29d1c34
·
verified ·
1 Parent(s): 154e49c

Upload LTAF ECG beat classifier (N/A/V), frozen Chronos-2 + MLP head

Browse files
Files changed (2) hide show
  1. README.md +77 -0
  2. best_classifier.pt +3 -0
README.md ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: pytorch
3
+ tags:
4
+ - ecg
5
+ - classification
6
+ - chronos-2
7
+ - ltaf
8
+ - arrhythmia
9
+ license: mit
10
+ ---
11
+
12
+ # LTAF ECG Beat Classifier (N / A / V)
13
+
14
+ Frozen **Chronos-2** (`amazon/chronos-2`) multivariate encoder + MLP head,
15
+ trained on the PhysioNet Long-Term Atrial Fibrillation (LTAF) database
16
+ for per-beat classification.
17
+
18
+ ## Classes
19
+
20
+ | Code | Expansion |
21
+ |------|-----------|
22
+ | N | Normal sinus-origin beat |
23
+ | A | Atrial premature contraction (APC / PAC / SVE) |
24
+ | V | Ventricular premature contraction (PVC / VE) |
25
+
26
+ `Q` (unclassifiable / paced, ~89 / 9 M in the LTAF subset) is dropped.
27
+
28
+ ## Input
29
+
30
+ - `(B, 2, 256)` — 2-lead ECG at **128 Hz**, 2-second window **centered on the R-peak sample**
31
+ - Per-channel z-scored
32
+ - LTAF leads: `ECG1`, `ECG2`
33
+
34
+ ## Checkpoint details
35
+
36
+ | Field | Value |
37
+ |---|---|
38
+ | `num_classes` | 3 |
39
+ | `class_names` | `["N", "A", "V"]` |
40
+ | `window_samples` | 256 (2 s @ 128 Hz) |
41
+ | `n_channels` | 2 |
42
+ | `chronos_model_id` | `amazon/chronos-2` |
43
+ | `freeze_encoder` | `true` (only the head's 395,267 params were trained) |
44
+ | Head | 2-layer MLP: `Linear(1024, 512) → ReLU → Dropout(0.3) → Linear(512, 3)` |
45
+
46
+ ## Usage
47
+
48
+ ```python
49
+ import torch
50
+ from huggingface_hub import hf_hub_download
51
+ from src.models.ts_llm.ecg_classifier import EcgRhythmClassifier
52
+
53
+ path = hf_hub_download("rmxjck/ltaf-ecg-beats-classifier", "best_classifier.pt")
54
+ model = EcgRhythmClassifier.load(path, device="cuda")
55
+
56
+ # x: (B, 2, 256) float32 at 128 Hz, z-scored, centered on R-peak
57
+ logits = model(x)
58
+ pred = logits.argmax(-1) # 0=N, 1=A, 2=V
59
+ ```
60
+
61
+ ## Training
62
+
63
+ Produced by `scripts/train_ecg_classifier.py` in
64
+ [rmxjck/TSLM-Arena](https://github.com/) on the LTAF-Haystack split
65
+ (67 train / 8 val / 9 test records, deterministic seed 42). N beats are
66
+ subsampled per epoch to `negative_k × n_nonN` (default 2.0) to balance
67
+ the 97 % N / 1.7 % A / 1.5 % V class distribution.
68
+
69
+ ```bash
70
+ .venv/bin/python3 scripts/train_ecg_classifier.py \
71
+ --label-class beats --epochs 30 --batch-size 128
72
+ ```
73
+
74
+ ## Not for clinical use
75
+
76
+ Research artifact only. Not FDA-cleared. Not suitable for triage,
77
+ diagnosis, or any patient-facing application.
best_classifier.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aa800ad254acc9151f020846e335a2c964e73f14ea0366950caea2bcb5f34f07
3
+ size 1583853