File size: 3,443 Bytes
0753b53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
---
license: mit
tags:
  - ecg
  - medical
  - pytorch
datasets:
  - custom
language:
  - en
pipeline_tag: other
---

# ECG Over-Read: Pre-trained Models for ECG Diagnosis

Pre-trained model weights for the paper **"Beyond Machine Interpretation: Learning from Expert Over-Reads Improves ECG Diagnosis"** (Under Review of MIDL 2026).

## Models

This repository contains 4 pre-trained models:

| Model | File | Description |
|-------|------|-------------|
| **Supervised** | `supervised/best.pt` | Baseline ResNet-50 multi-label classifier |
| **CLIP** | `clip/best_cliponly.ckpt` | ECG-Text contrastive learning model |
| **NegCLIP** | `negclip/best_detail.ckpt` | CLIP with hard negative mining |
| **Self-Training** | `selftraining/best.pt` | Semi-supervised learning with FixMatch |

## Model Architecture

### ECG Encoder (All Models)
- **Architecture**: 1D ResNet-50 with bottleneck blocks (3-4-6-3)
- **Input**: 12-lead ECG signal `(batch, 12, 2500)` at 250 Hz
- **Output**: 512-dimensional embedding
- **Preprocessing**: High-pass filter (0.5 Hz), Notch filter (60 Hz), Per-lead z-score

### Text Encoder (CLIP/NegCLIP)
- **Architecture**: CLIP text encoder
- **Output**: 512-dimensional embedding (projected)

## Usage

### Download Weights

```python
from huggingface_hub import hf_hub_download

# Download supervised model
model_path = hf_hub_download(
    repo_id="tyoung089/ECG_overread",
    filename="supervised/best.pt"
)

# Load model
import torch
checkpoint = torch.load(model_path, map_location="cpu")
```

### Using with Our Code

```bash
# Clone the code repository
git clone https://github.com/YOUR_USERNAME/ecg-overread.git
cd ecg-overread

# Download all weights
pip install huggingface_hub
python download_weights.py --outdir ./weights

# Run evaluation
python Supervised/ecg_eval_cls.py \
    --csv /path/to/test.csv \
    --ckpt ./weights/supervised/best.pt \
    --label-prefix "label_diag__"
```

## Input Data Format

### ECG Signal
- **Sampling rate**: 250 Hz
- **Duration**: 10 seconds
- **Leads**: 12-lead standard ECG
- **Shape**: `(2500, 12)` or `(12, 2500)`
- **Format**: NumPy `.npy` files

### Checkpoint Format

**Supervised / Self-Training (`best.pt`)**:
```python
{
    "model": state_dict,           # Model weights
    "opt": optimizer_state,        # Optimizer state
    "sched": scheduler_state,      # Scheduler state
    "epoch": int,                  # Training epoch
    "best": float,                 # Best validation metric
    "classes": list,               # Class names
}
```

**CLIP / NegCLIP (`.ckpt`)**:
```python
{
    "model": state_dict,           # Full model (ECG + Text encoder)
    "epoch": int,
    "args": training_args,
}
```

## Training Details

| Model | Training Data | Method |
|-------|--------------|--------|
| Supervised | Labeled ECGs | Multi-label BCE loss |
| CLIP | ECG + Text pairs | Symmetric contrastive loss |
| NegCLIP | ECG + Text pairs | Contrastive loss with hard negatives |
| Self-Training | Labeled + Unlabeled | FixMatch with pseudo-labels |

## License

MIT License

## Citation

```bibtex
@inproceedings{overread2026midl,
  title={Beyond Machine Interpretation: Learning from Expert Over-Reads Improves ECG Diagnosis},
  author={Kwak et al.},
  booktitle={Under Review for Medical Imaging with Deep Learning (MIDL)},
  year={2026}
}
```

## Links

- **Code Repository**: [GitHub](https://github.com/tyoung089/ecg-overread)
- **Paper**: Coming soon