Upload released checkpoint (regression loss), ONNX export, and model card
Browse files- README.md +83 -0
- best.ckpt +3 -0
- efficientnet_b0_regression_512px.onnx +3 -0
README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: research-use-only
|
| 4 |
+
license_link: https://github.com/adarshcod30/Diabetic-Retinopathy-Detection/blob/main/MODEL_CARD.md
|
| 5 |
+
tags:
|
| 6 |
+
- diabetic-retinopathy
|
| 7 |
+
- medical-imaging
|
| 8 |
+
- fundus
|
| 9 |
+
- explainable-ai
|
| 10 |
+
- efficientnet
|
| 11 |
+
- pytorch
|
| 12 |
+
- onnx
|
| 13 |
+
library_name: pytorch
|
| 14 |
+
pipeline_tag: image-classification
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# drdetect: Diabetic Retinopathy Screening Model
|
| 18 |
+
|
| 19 |
+
**Research prototype. NOT a medical device. NOT a substitute for clinical judgement.**
|
| 20 |
+
|
| 21 |
+
EfficientNet-B0 (regression-loss ordinal head) for 5-class ICDR diabetic retinopathy grading,
|
| 22 |
+
trained on APTOS 2019 and evaluated once, honestly, on a locked external test set (Messidor-2 +
|
| 23 |
+
IDRiD). Full code, every experiment, and the complete evidence trail:
|
| 24 |
+
[github.com/adarshcod30/Diabetic-Retinopathy-Detection](https://github.com/adarshcod30/Diabetic-Retinopathy-Detection).
|
| 25 |
+
|
| 26 |
+
## Why this checkpoint
|
| 27 |
+
|
| 28 |
+
This is **not** the checkpoint with the best internal-validation accuracy — a plain
|
| 29 |
+
cross-entropy baseline scored higher there. It is the checkpoint that won a **pre-registered,
|
| 30 |
+
one-time external evaluation** on data neither model was tuned on: referable-DR AUC 0.9242 vs.
|
| 31 |
+
0.8878 for the CE baseline (DeLong test, p=6.1×10⁻¹⁰). See the full write-up:
|
| 32 |
+
[`docs/22_PHASE8_VALIDATION_RESULTS.md`](https://github.com/adarshcod30/Diabetic-Retinopathy-Detection/blob/main/docs/22_PHASE8_VALIDATION_RESULTS.md).
|
| 33 |
+
|
| 34 |
+
## Files
|
| 35 |
+
|
| 36 |
+
- `best.ckpt` — PyTorch Lightning checkpoint (EfficientNet-B0, regression head, 512×512 input).
|
| 37 |
+
- `efficientnet_b0_regression_512px.onnx` — ONNX export, parity-verified against the PyTorch
|
| 38 |
+
module (max abs diff 2.4×10⁻⁷).
|
| 39 |
+
|
| 40 |
+
## Headline results (locked external test, run once)
|
| 41 |
+
|
| 42 |
+
| | QWK | Sensitivity | Specificity | Referable AUC |
|
| 43 |
+
|---|---:|---:|---:|---:|
|
| 44 |
+
| This model | 0.6995 | 0.441 | 0.976 | 0.9242 |
|
| 45 |
+
|
| 46 |
+
**Read the limitation, not just the AUC**: referable-DR sensitivity is 44.1% against a >=90%
|
| 47 |
+
target — well below every published comparator. This is diagnosed (not just disclosed) as a
|
| 48 |
+
threshold-transfer/calibration failure, not a pure discrimination failure: the frozen operating
|
| 49 |
+
threshold from internal validation does not transfer to this external population, even though the
|
| 50 |
+
model's ranking ability (AUC) held up in a range comparable to a cited external-validation drop in
|
| 51 |
+
the literature. **Any real use of this model's binary referable/non-referable output requires
|
| 52 |
+
fitting a new threshold on a local calibration set first.** Full detail:
|
| 53 |
+
[`MODEL_CARD.md`](https://github.com/adarshcod30/Diabetic-Retinopathy-Detection/blob/main/MODEL_CARD.md).
|
| 54 |
+
|
| 55 |
+
## Usage
|
| 56 |
+
|
| 57 |
+
```python
|
| 58 |
+
import torch
|
| 59 |
+
from drdetect.grading.model import build_model # from the GitHub repo's src/
|
| 60 |
+
|
| 61 |
+
model = build_model("efficientnet_b0", num_outputs=1, pretrained=False, freeze_bn=True)
|
| 62 |
+
ckpt = torch.load("best.ckpt", map_location="cpu", weights_only=False)
|
| 63 |
+
state = ckpt.get("state_dict", ckpt)
|
| 64 |
+
state = {k.removeprefix("model."): v for k, v in state.items() if k.startswith("model.")}
|
| 65 |
+
model.load_state_dict(state)
|
| 66 |
+
model.eval()
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
Or with the repo's own pipeline (handles preprocessing, quality gating, and decoding):
|
| 70 |
+
|
| 71 |
+
```python
|
| 72 |
+
from drdetect.serve.pipeline import load_grader, run_pipeline
|
| 73 |
+
|
| 74 |
+
model = load_grader("best.ckpt", backbone="efficientnet_b0", loss_name="regression", device="cpu")
|
| 75 |
+
result = run_pipeline(image_rgb, model, loss_name="regression", size=512, device="cpu")
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
## License
|
| 79 |
+
|
| 80 |
+
**Research use only.** Derived from training data under mixed licenses that restrict
|
| 81 |
+
redistribution (APTOS/Kaggle competition rules, Messidor-2's ADCIS terms) — see
|
| 82 |
+
[`DATASET_CARD.md`](https://github.com/adarshcod30/Diabetic-Retinopathy-Detection/blob/main/DATASET_CARD.md).
|
| 83 |
+
Not licensed for any clinical, diagnostic, or commercial product.
|
best.ckpt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d68840814a7bfb0673ef965a0aa8d9bb1a3709bc38eb293fc9797ec5ec8a95dc
|
| 3 |
+
size 48168567
|
efficientnet_b0_regression_512px.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cfe524225ca55b507e5bf9256985014c6aec68d8c75563a33b9b985d78e42790
|
| 3 |
+
size 16018283
|