Instructions to use Steenslid/ecg-ptbxl-classification with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use Steenslid/ecg-ptbxl-classification with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://Steenslid/ecg-ptbxl-classification") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from Steenslid/ecg-ptbxl-classification: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/Steenslid/ecg-ptbxl-classification/resolve/main/README.md
- Command line
-
hf download hf://Steenslid/ecg-ptbxl-classification/README.md
-
curl -L -o README.md https://huggingface.co/Steenslid/ecg-ptbxl-classification/resolve/main/README.md
1.33 kB
| 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 | |