File size: 1,331 Bytes
1e1abc0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
tags:
  - ecg
  - cardiovascular
  - multi-label-classification
  - keras
  - ptb-xl
datasets:
  - ptb-xl
license: mit
---

# ECG Cardiovascular Disease Classification

Multi-label classification of 5 cardiovascular superclasses
(NORM, MI, STTC, CD, HYP) from 12-lead ECG recordings, trained on PTB-XL.

**Deployed model**: CNN (noaug training variant)

## Files

- `ecg_model.keras` | trained  model
- `normalisation_params.npz` | per-channel mean and std (z-score, from training fold)
- `thresholds.json` | per-class decision thresholds optimised on the validation fold

## Usage

```python
import keras, numpy as np, json
from huggingface_hub import hf_hub_download

model = keras.saving.load_model(
    hf_hub_download("Steenslid/ecg-ptbxl-classification", "ecg_model.keras"))
params = np.load(hf_hub_download("Steenslid/ecg-ptbxl-classification", "normalisation_params.npz"))
with open(hf_hub_download("Steenslid/ecg-ptbxl-classification", "thresholds.json")) as f:
    thresholds = json.load(f)

# Input x: (1000, 12) float32 ECG in mV, 100 Hz, standard 12-lead order
x_norm = (x - params["mean"]) / params["std"]
probs = model.predict(x_norm[np.newaxis])[0]
preds = {sc: probs[i] >= thresholds[sc] for i, sc in enumerate(
    ["NORM","MI","STTC","CD","HYP"])}
```

**Authors:** Edvard Vindenes Steenslid & Morten Kvamme