gaoyua19 nielsr HF Staff commited on
Commit
8c3140e
·
verified ·
1 Parent(s): c5d3ac4

Improve model card: Add paper link, pipeline tag, specific license, and sample usage (#3)

Browse files

- Improve model card: Add paper link, pipeline tag, specific license, and sample usage (656984de2f31020d04db0098dab96221323220f8)


Co-authored-by: Niels Rogge <[email protected]>

Files changed (1) hide show
  1. README.md +70 -4
README.md CHANGED
@@ -1,19 +1,29 @@
1
  ---
2
- license: cc-by-4.0
3
  language:
4
  - en
 
5
  tags:
6
  - ecg
7
  - student-teacher
8
  - echocardiograms
 
 
9
  ---
10
- # EchoingECG
 
 
 
11
 
12
  EchoingECG is a probabilistic student-teacher model designed to improve cardiac function prediction from electrocardiograms (ECGs) by distilling knowledge from echocardiograms (ECHO). This approach leverages uncertainty-aware ECG embeddings and ECHO supervision, integrating Probabilistic Cross-Modal Embeddings (PCME++) and ECHO-CLIP, a vision-language pretrained model, to transfer ECHO knowledge into ECG representations.
13
 
14
- Please refer to our github for use: https://github.com/mcintoshML/EchoingECG
15
 
16
- ![EchoingECG Overview](assets/fig1_overview.png)
 
 
 
 
 
17
 
18
  ## Installation
19
  Clone the repository and install dependencies:
@@ -23,6 +33,62 @@ cd EchoingECG
23
  pip install -r requirements.txt
24
  ```
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  ## Citation
27
  If you use EchoingECG in your research, please cite:
28
  ```
 
1
  ---
 
2
  language:
3
  - en
4
+ license: cc-by-nc-nd-4.0
5
  tags:
6
  - ecg
7
  - student-teacher
8
  - echocardiograms
9
+ - medical
10
+ pipeline_tag: other
11
  ---
12
+
13
+ # EchoingECG: An Electrocardiogram Cross-Modal Model for Echocardiogram Tasks
14
+
15
+ The model was presented in the paper [EchoingECG: An Electrocardiogram Cross-Modal Model for Echocardiogram Tasks](https://huggingface.co/papers/2509.25791).
16
 
17
  EchoingECG is a probabilistic student-teacher model designed to improve cardiac function prediction from electrocardiograms (ECGs) by distilling knowledge from echocardiograms (ECHO). This approach leverages uncertainty-aware ECG embeddings and ECHO supervision, integrating Probabilistic Cross-Modal Embeddings (PCME++) and ECHO-CLIP, a vision-language pretrained model, to transfer ECHO knowledge into ECG representations.
18
 
19
+ You can find the official code and further details on our [GitHub repository](https://github.com/mcintoshML/EchoingECG).
20
 
21
+ ## Features
22
+ - ECHO-CLIP knowledge distillation
23
+ - Probabilistic contrastive learning with PCME++
24
+ - Outperforms state-of-the-art ECG models for ECHO prediction
25
+
26
+ ![EchoingECG Overview](https://huggingface.co/mcintoshML/EchoingECG/resolve/main/assets/fig1_overview.png)
27
 
28
  ## Installation
29
  Clone the repository and install dependencies:
 
33
  pip install -r requirements.txt
34
  ```
35
 
36
+ ## Quick Start: Run EchoingECG in Jupyter Notebook
37
+ Below is an example workflow using the provided demo notebook:
38
+
39
+ ```python
40
+ import sys
41
+ import yaml
42
+ import torch
43
+ from src.model.echoingecg_model import EchoingECG
44
+
45
+ # Load model config
46
+ with open("src/configs/model.yaml") as f:
47
+ model_cfg = yaml.safe_load(f)
48
+ model = EchoingECG(model_cfg)
49
+ model_weights = torch.load("echoingecg.pt", weights_only=True, map_location="cpu")
50
+ model.load_state_dict(model_weights)
51
+
52
+ # Example ECG input
53
+ dummy_ecg = torch.zeros((1, 12, 1000)) # 10 seconds at 100Hz, 12 leads
54
+ input = {"ecg": dummy_ecg}
55
+ output = model(input)
56
+ print(output["ecg"].keys()) # 'mean' and 'std' (probabilistic)
57
+ print(output["ecg"]["mean"].shape, output["ecg"]["std"].shape)
58
+
59
+ # Example text input
60
+ from transformers import AutoTokenizer
61
+ text_example = "ecg is normal"
62
+ tokenizer = AutoTokenizer.from_pretrained("dmis-lab/biobert-v1.1", return_pt=True)
63
+ tok_dict = tokenizer(text_example)
64
+ input_model = {
65
+ "text": torch.tensor(tok_dict["input_ids"]).unsqueeze(0),
66
+ "attention_mask": torch.tensor(tok_dict["attention_mask"]).unsqueeze(0)
67
+ }
68
+ output = model(input_model)
69
+ print(output["text"].keys()) # 'mean' and 'std'
70
+ print(output["text"]["mean"].shape, output["text"]["std"].shape)
71
+
72
+ # Load and scale an ECG properly
73
+ from src.datasets.helpers import scale_ecg
74
+ import joblib
75
+ import numpy as np
76
+ sc = joblib.load("ecg_scaler.pkl")
77
+ _center = torch.from_numpy(sc.mean_.astype(np.float32))
78
+ _scale = torch.from_numpy(sc.scale_.astype(np.float32)).clamp_min(1e-8)
79
+ dummy_ecg = torch.zeros((1,12,1000))
80
+ scaled_output = scale_ecg(_center, _scale, dummy_ecg)
81
+ ```
82
+
83
+ ## License
84
+ This work is licensed under the **Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License (CC BY-NC-ND 4.0)**.
85
+
86
+ You may share this work for non-commercial purposes, with proper attribution, but you may not modify it or use it commercially.
87
+
88
+ [![Creative Commons License](https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png)](https://creativecommons.org/licenses/by-nc-nd/4.0/)
89
+
90
+ [View Full License Details](https://creativecommons.org/licenses/by-nc-nd/4.0/)
91
+
92
  ## Citation
93
  If you use EchoingECG in your research, please cite:
94
  ```