Instructions to use hellothisisaswin/ecg-ptbxl-classification with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use hellothisisaswin/ecg-ptbxl-classification with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://hellothisisaswin/ecg-ptbxl-classification") - Notebooks
- Google Colab
- Kaggle
| 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 | |