File size: 5,888 Bytes
c11dca9
 
 
 
 
 
 
 
fa50b6c
 
 
c11dca9
 
 
 
 
fa50b6c
 
c11dca9
 
 
 
fa50b6c
 
 
 
 
c11dca9
 
 
fa50b6c
c11dca9
fa50b6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c11dca9
fa50b6c
 
c11dca9
 
 
 
fa50b6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c11dca9
fa50b6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c11dca9
 
 
 
fa50b6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c11dca9
fa50b6c
 
 
 
 
 
 
 
 
 
 
c11dca9
fa50b6c
 
 
 
 
 
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
---
license: mit
tags:
  - medical-imaging
  - ophthalmology
  - image-classification
  - explainable-ai
  - grad-cam
  - core-ml
  - resnet
  - pytorch
language:
  - zh
  - en
metrics:
  - roc_auc
  - f1
pipeline_tag: image-classification
---

# ELIAS — Eyelid Lesion Intelligent Analysis System

**眼瞼疾病智慧分析系統**

> 🏆 2026 年經濟部智慧創新大賞(學生組)參賽作品

---

## Model Description

ELIAS is a **clinician-guided deep learning classifier** for automated detection of **epiblepharon** (睫毛倒插) from external eye photographs.

The model uses a **frozen ImageNet-pretrained ResNet-18 backbone** with a task-specific classification head. The key innovation is the explicit integration of clinician-defined anatomical **Regions of Interest (ROI)** — specifically the lower eyelid margin and eyelash–cornea interface — as a prior constraint, enabling robust classification in a **small-data regime (~80–150 cases per class)**.

### Architecture

```
Input (224×224 RGB)


ResNet-18 backbone (frozen, ImageNet pretrained)
    │  layer1 → layer2 → layer3 → layer4
    │  Global Average Pooling → (512,)

Dropout(0.3) → Linear(512 → 2)


Softmax → [P(control), P(epiblepharon)]
```

| Component | Detail |
|---|---|
| Backbone | ResNet-18 (ImageNet pretrained, **fully frozen**) |
| Classification head | `Dropout(0.3)` + `Linear(512 → 2)` |
| Loss function | `CrossEntropyLoss` |
| Optimizer | `Adam(lr=1e-3)`, head parameters only |
| Input size | 224 × 224 px, RGB (Grayscale → 3ch conversion applied) |
| Normalization | ImageNet mean/std `[0.485, 0.456, 0.406]` / `[0.229, 0.224, 0.225]` |

---

## Performance

Evaluated by **stratified 5-fold cross-validation** (`random_state=42`, 20 epochs/fold).

| Metric | Mean (5-fold) |
|---|---|
| **AUC** | **0.93** |
| Accuracy | High |
| Sensitivity | High |
| Specificity | Moderate |
| F1 Score | High |

- ✅ No fold collapse observed across all 5 folds
- ✅ Label-shuffling negative control confirmed genuine feature learning
- ✅ ROI ablation experiments validated lower eyelid margin as primary diagnostic signal

### ROI Ablation Summary

| Condition | Performance vs Baseline |
|---|---|
| Full image (baseline) | ✅ Optimal |
| ROI ablated (lower eyelid blurred) | ❌ Significant drop |
| Non-ROI ablated (ROI preserved) | ✅ Near-baseline |

> Diagnostic features are **spatially localized** to the clinically defined lower eyelid margin — consistent with clinical examination principles for epiblepharon.

---

## Grad-CAM Explainability

Grad-CAM heatmaps were generated using native PyTorch hooks on `layer4` (no Captum dependency):

- **Epiblepharon cases**: Activation consistently focused on **lower eyelid margin and eyelash–cornea interface**
- **Control cases**: Diffuse, anatomically unfocused activation patterns

Heatmap overlay: α = 0.45, JET colormap, bilinear upsampling to 224×224.

---

## iOS On-Device Inference

The trained model has been converted to **Apple Core ML** format (`.mlpackage`):

| Metric | Value |
|---|---|
| Model size | < 50 MB |
| Inference latency | **< 1 second / image** |
| Device | iPhone 12+ (A14+ Neural Engine) |
| Network required | ❌ None — fully on-device |

Privacy: facial images never leave the device, consistent with PDPA / HIPAA principles.

---

## Training Data

- **Task**: Binary classification — epiblepharon vs. control
- **Image type**: External eye photographs
- **Dataset size**: ~80–150 cases per class (single-center, retrospective)
- **Preprocessing**: Resize 224×224, Grayscale→3ch, ColorJitter, RandomHorizontalFlip, ImageNet normalization

> ⚠️ Clinical images are **not distributed** in this repository due to patient privacy regulations (Personal Data Protection Act, IRB). For academic collaboration, please contact the corresponding author.

---

## Usage

```python
import torch
from torchvision import models, transforms
from PIL import Image

# Load model
model = models.resnet18(weights=None)
for param in model.parameters():
    param.requires_grad = False
model.fc = torch.nn.Linear(model.fc.in_features, 2)
model.load_state_dict(torch.load("pytorch_model.pt", map_location="cpu"))
model.eval()

# Preprocess
transform = transforms.Compose([
    transforms.Resize((224, 224)),
    transforms.Grayscale(num_output_channels=3),
    transforms.ToTensor(),
    transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
])

img = Image.open("eye_photo.jpg").convert("RGB")
x = transform(img).unsqueeze(0)  # (1, 3, 224, 224)

with torch.no_grad():
    logits = model(x)
    prob = torch.softmax(logits, dim=1)[0, 1].item()
    print(f"Epiblepharon probability: {prob:.3f}")
```

---

## Files in This Repository

| File | Description |
|---|---|
| `README.md` | This model card |
| `model.py` | Model architecture definition |
| `train.py` | 5-fold cross-validation training script |
| `config.json` | Model configuration |
| `requirements.txt` | Python dependencies |
| `pytorch_model.pt` | *(Checkpoint — upload separately after training)* |

---

## Intended Use & Limitations

- **Intended use**: Research prototype for clinical decision support in epiblepharon screening
- **NOT** a validated medical device — prospective evaluation and regulatory assessment required before clinical deployment
- Single-center retrospective data — generalizability across imaging conditions and demographics requires multi-center validation

---

## Citation

```bibtex
@misc{elias2026,
  title     = {ELIAS: Eyelid Lesion Intelligent Analysis System},
  year      = {2026},
  note      = {2026 MOEA Smart Innovation Award submission},
  url       = {https://huggingface.co/YOUR_HF_USERNAME/ELIAS-epiblepharon}
}
```

---

## License

[MIT License](LICENSE) — Source code only. Clinical data excluded.