RanveerSoni98 commited on
Commit
4ce7f95
Β·
verified Β·
1 Parent(s): 4c5f2d1

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +7 -97
README.md CHANGED
@@ -42,7 +42,7 @@ model-index:
42
  value: 0.9814
43
  ---
44
 
45
- # πŸ›‘οΈ Aegis Stage 1 β€” Binary Cancer Detector (EfficientNet-B0)
46
 
47
  **Aegis Stage 1** is a lightweight, high-sensitivity binary classifier trained on **30,453 histopathology tiles** across 6 public datasets to distinguish **cancerous** from **non-cancerous** tissue. It serves as the first stage in the Aegis cascaded pipeline for automated cancer detection and OncoTree subtype classification.
48
 
@@ -57,7 +57,7 @@ model-index:
57
 
58
  ---
59
 
60
- ## πŸ“Š Performance Benchmarks (Unseen Test Set)
61
 
62
  Evaluated across **3,528 unseen histopathology test tiles** (6 datasets):
63
 
@@ -77,96 +77,7 @@ At threshold `0.32`, the model achieves **95.07% cancer recall** with **89.32% s
77
 
78
  ---
79
 
80
- ## πŸ“¦ Model Artifacts Included
81
-
82
- | File | Description | Size |
83
- |:---|:---|:---|
84
- | `checkpoint_best_recall.pt` | Best PyTorch checkpoint (optimized for recall) | 16.3 MB |
85
- | `stage1_int8.onnx` | INT8 signed quantized ONNX (MatMul+Gemm only) | 15.7 MB |
86
- | `stage1.onnx` + `stage1.onnx.data` | Full FP32 ONNX model | 32.4 MB |
87
- | `metrics.json` | Training history & validation metrics | 4.4 KB |
88
- | `eval_test_metrics.json` | Full test-set evaluation (per-dataset) | 13 KB |
89
- | `config.yaml` | Training hyperparameters & data config | 1.1 KB |
90
-
91
- ---
92
-
93
- ## πŸš€ Quickstart Usage
94
-
95
- ### PyTorch Inference
96
-
97
- ```python
98
- import torch
99
- import timm
100
- from PIL import Image
101
- from torchvision import transforms
102
-
103
- # 1. Load Model
104
- model = timm.create_model("efficientnet_b0", pretrained=False, num_classes=1)
105
- checkpoint = torch.load("checkpoint_best_recall.pt", map_location="cpu")
106
- model.load_state_dict(checkpoint["model_state_dict"])
107
- model.eval()
108
-
109
- # 2. Preprocess Tile (224x224, ImageNet normalization)
110
- transform = transforms.Compose([
111
- transforms.Resize((224, 224)),
112
- transforms.ToTensor(),
113
- transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
114
- ])
115
-
116
- image = Image.open("tile_sample.png").convert("RGB")
117
- tensor = transform(image).unsqueeze(0)
118
-
119
- # 3. Predict (logit > 0 = cancerous)
120
- with torch.no_grad():
121
- logit = model(tensor).item()
122
- prob = torch.sigmoid(torch.tensor(logit)).item()
123
-
124
- label = "CANCEROUS" if logit > 0 else "BENIGN"
125
- confidence = prob if logit > 0 else 1 - prob
126
- print(f"Prediction: {label} ({confidence*100:.1f}%)")
127
- ```
128
-
129
- ### ONNX Runtime Inference (INT8 Optimized)
130
-
131
- ```python
132
- import onnxruntime as ort
133
- import numpy as np
134
- from PIL import Image
135
-
136
- session = ort.InferenceSession("stage1_int8.onnx")
137
-
138
- # Load and preprocess
139
- img = Image.open("tile_sample.png").convert("RGB").resize((224, 224))
140
- arr = np.array(img, dtype=np.float32) / 255.0
141
- arr = (arr - np.array([0.485, 0.456, 0.406])) / np.array([0.229, 0.224, 0.225])
142
- tensor = np.expand_dims(np.transpose(arr, (2, 0, 1)), axis=0).astype(np.float32)
143
-
144
- # Run ONNX inference
145
- inp_name = session.get_inputs()[0].name
146
- logit = session.run(None, {inp_name: tensor})[0][0][0]
147
- prob = 1 / (1 + np.exp(-logit))
148
-
149
- label = "CANCEROUS" if logit > 0 else "BENIGN"
150
- confidence = prob if logit > 0 else 1 - prob
151
- print(f"Prediction: {label} ({confidence*100:.1f}%)")
152
- ```
153
-
154
- ### High-Recall Mode (Screening Threshold)
155
-
156
- ```python
157
- # Use lower threshold for maximum cancer recall
158
- HIGH_RECALL_THRESHOLD = 0.32 # logit threshold
159
-
160
- logit = model(tensor).item()
161
- if logit > HIGH_RECALL_THRESHOLD:
162
- print("πŸ”΄ FLAG: Potential cancer detected (high-recall mode)")
163
- else:
164
- print("🟒 Benign / Normal")
165
- ```
166
-
167
- ---
168
-
169
- ## πŸ“š Dataset Attribution & Citation
170
 
171
  This model was trained on public histopathology research datasets:
172
 
@@ -178,25 +89,24 @@ This model was trained on public histopathology research datasets:
178
 
179
  ---
180
 
181
- ## ⚠️ Medical Research Disclaimer
182
 
183
  **Aegis is an open-source AI research prototype intended for educational, scientific evaluation, and research purposes only.** It is not a certified medical device and must not be used for primary clinical diagnosis or treatment planning.
184
 
185
  ---
186
 
187
- ## πŸ”— Related Models
188
 
189
  - **Stage 2 OncoTree Subtype Classifier**: [`AegisOSS/stage-2`](https://huggingface.co/AegisOSS/stage-2) β€” 9-class ResNet-50 for cancer subtyping
190
- - **Full Cascade Pipeline**: See [Aegis Repository](https://github.com/AegisOSS/aegis) for cascaded inference
191
 
192
  ---
193
 
194
- ## πŸ“„ Citation
195
 
196
  ```bibtex
197
  @software{aegis_stage1,
198
  title = {Aegis Stage 1: EfficientNet-B0 Binary Cancer Detector for Histopathology},
199
- author = {Aegis Research Team},
200
  year = {2026},
201
  url = {https://huggingface.co/AegisOSS/stage-1},
202
  license = {CC-BY-4.0}
 
42
  value: 0.9814
43
  ---
44
 
45
+ # Aegis Stage 1 β€” Binary Cancer Detector (EfficientNet-B0)
46
 
47
  **Aegis Stage 1** is a lightweight, high-sensitivity binary classifier trained on **30,453 histopathology tiles** across 6 public datasets to distinguish **cancerous** from **non-cancerous** tissue. It serves as the first stage in the Aegis cascaded pipeline for automated cancer detection and OncoTree subtype classification.
48
 
 
57
 
58
  ---
59
 
60
+ ## Performance Benchmarks (Unseen Test Set)
61
 
62
  Evaluated across **3,528 unseen histopathology test tiles** (6 datasets):
63
 
 
77
 
78
  ---
79
 
80
+ ## Dataset Attribution & Citation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
  This model was trained on public histopathology research datasets:
83
 
 
89
 
90
  ---
91
 
92
+ ## Medical Research Disclaimer
93
 
94
  **Aegis is an open-source AI research prototype intended for educational, scientific evaluation, and research purposes only.** It is not a certified medical device and must not be used for primary clinical diagnosis or treatment planning.
95
 
96
  ---
97
 
98
+ ## Related Models
99
 
100
  - **Stage 2 OncoTree Subtype Classifier**: [`AegisOSS/stage-2`](https://huggingface.co/AegisOSS/stage-2) β€” 9-class ResNet-50 for cancer subtyping
 
101
 
102
  ---
103
 
104
+ ## Citation
105
 
106
  ```bibtex
107
  @software{aegis_stage1,
108
  title = {Aegis Stage 1: EfficientNet-B0 Binary Cancer Detector for Histopathology},
109
+ author = {Ranveer Soni},
110
  year = {2026},
111
  url = {https://huggingface.co/AegisOSS/stage-1},
112
  license = {CC-BY-4.0}