PTB-XL ECG ResNet
A compact model for ECG analysis
2 min readupdated
The model is a compact 1D AI model (ResNet) with about 0.19 million parameters that evaluates 10-second 12-lead electrocardiograms (ECGs) at 100 Hz. It predicts five diagnostic superclasses from the PTB-XL database: normal, myocardial infarction, ST/T changes, conduction disturbances, and hypertrophy. The solution is intended exclusively for research purposes and is not a medical device or diagnostic tool. The developers implemented a confidence mechanism: with a threshold of 0.8, the model processes some of the records and sends the rest for expert review.
Key features
- High quality: Macro-AUROC on the official test set is 0.925.
- Compactness: Only about 0.19 million parameters thanks to the 1D ResNet architecture.
- Reproducibility: Trained on the official patient-split folds of the PTB-XL 1.0.3 dataset.
- Confidence control: Built-in thresholds and a abstention rule for low confidence.
What you can do
- ECG research: Conduct experiments on automatic classification of heart rhythms and pathologies on datasets.
- Benchmarking: Compare the performance of 1D ResNet with other architectures (for example, classical 1D CNNs).
- Pipeline integration: Use the checkpoint and code for digital signal analysis in Python scripts.
Example
import json, numpy as np, torch
from huggingface_hub import hf_hub_download
import importlib.util
repo = "MHkhan50/ptbxl-ecg-resnet"
cfg = json.load(open(hf_hub_download(repo, "config.json")))
spec = importlib.util.spec_from_file_location("model", hf_hub_download(repo, "model.py"))
m = importlib.util.module_from_spec(spec); spec.loader.exec_module(m)
net = m.ECGResNet(num_labels=5, channels=(32, 64, 128), dropout=0.2)
net.load_state_dict(torch.load(hf_hub_download(repo, "resnet_s23_best.pt"), weights_only=True)["model_state_dict"])
net.eval()
Read more
DetailsBenchmarks: AUROC by class — NORM (0.941), MI (0.927), STTC (0.931), CD (0.920), HYP (0.904), macro-AUROC 0.925.
Data: PTB-XL 1.0.3 (21,388 records), trained on Kaggle T4 GPU using AdamW.
Limitations: For research only, dataset collected in a single German center (1989–1996), no external validation.
License: Weights under CC BY 4.0, code under MIT.










Comments