Trustcat commited on
Commit
e9ac819
·
verified ·
1 Parent(s): 360469f

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +105 -0
README.md ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - medical
5
+ - ecg
6
+ - cardiology
7
+ - classification
8
+ - pytorch
9
+ - trustcat
10
+ datasets:
11
+ - ptb-xl
12
+ metrics:
13
+ - f1
14
+ pipeline_tag: audio-classification
15
+ ---
16
+
17
+ # QueenBee-ECG Classifier
18
+
19
+ **1D ResNet for 12-lead ECG diagnostic classification on PTB-XL**
20
+
21
+ Part of the TrustCat sovereign medical AI stack.
22
+
23
+ ## Model Description
24
+
25
+ Classifies 12-lead ECGs into 5 diagnostic superclasses:
26
+
27
+ | Class | Description | Test F1 |
28
+ |-------|-------------|---------|
29
+ | NORM | Normal ECG | 81% |
30
+ | MI | Myocardial Infarction | 62% |
31
+ | STTC | ST-T Changes | 58% |
32
+ | CD | Conduction Disturbance | 57% |
33
+ | HYP | Hypertrophy | 31% |
34
+
35
+ ## Performance
36
+
37
+ | Metric | Value |
38
+ |--------|-------|
39
+ | Macro F1 | 58% |
40
+ | Accuracy | 67% |
41
+ | Weighted F1 | 68% |
42
+
43
+ ## Architecture
44
+
45
+ - **Type**: 1D ResNet
46
+ - **Parameters**: 8.7M
47
+ - **Input**: 12-lead ECG (1000 samples @ 100Hz = 10 seconds)
48
+ - **Output**: 5-class probability distribution
49
+
50
+ ## Training
51
+
52
+ - **Dataset**: PTB-XL (17,084 train / 2,146 val / 2,158 test)
53
+ - **Hardware**: 2x RTX 5090
54
+ - **Epochs**: 18 (early stopping)
55
+ - **Training Time**: ~3 minutes
56
+ - **Optimizer**: AdamW
57
+ - **Loss**: Cross-entropy with class weights
58
+
59
+ ## Usage
60
+
61
+ ```python
62
+ import torch
63
+ import wfdb
64
+ from model import ECGResNet # See training script
65
+
66
+ # Load model
67
+ model = ECGResNet(n_classes=5)
68
+ checkpoint = torch.load("best_model.pt")
69
+ model.load_state_dict(checkpoint['model_state_dict'])
70
+ model.eval()
71
+
72
+ # Load ECG (12-lead, 10 seconds @ 100Hz)
73
+ signal, _ = wfdb.rdsamp("path/to/ecg")
74
+ signal = (signal - signal.mean(0)) / (signal.std(0) + 1e-8)
75
+ x = torch.tensor(signal.T, dtype=torch.float32).unsqueeze(0)
76
+
77
+ # Predict
78
+ with torch.no_grad():
79
+ logits = model(x)
80
+ pred = logits.argmax(dim=1).item()
81
+
82
+ classes = ["NORM", "MI", "STTC", "CD", "HYP"]
83
+ print(f"Prediction: {classes[pred]}")
84
+ ```
85
+
86
+ ## Intended Use
87
+
88
+ - Clinical decision support
89
+ - ECG screening assistance
90
+ - Cardiology research
91
+
92
+ ## Limitations
93
+
94
+ - Trained on PTB-XL dataset only
95
+ - Not FDA cleared
96
+ - HYP class has weak performance (small training set)
97
+ - Requires clinical validation
98
+
99
+ ## License
100
+
101
+ Apache 2.0
102
+
103
+ ---
104
+
105
+ **Built with diamond hands by TrustCat - Sovereign Medical AI**