File size: 5,594 Bytes
e44895f
 
 
 
 
 
 
 
 
 
 
 
c2b283c
 
 
e44895f
 
c2b283c
e44895f
c2b283c
e44895f
c2b283c
e44895f
c2b283c
e44895f
c2b283c
 
 
 
 
 
 
 
 
 
 
 
 
 
e44895f
 
 
 
c2b283c
e44895f
c2b283c
 
 
e44895f
 
c2b283c
 
 
e44895f
c2b283c
e44895f
 
 
c2b283c
 
 
 
e44895f
 
c2b283c
 
 
e44895f
c2b283c
e44895f
c2b283c
e44895f
c2b283c
 
 
e44895f
c2b283c
 
 
 
 
 
e44895f
c2b283c
e44895f
 
 
 
 
c2b283c
 
e44895f
c2b283c
 
 
e44895f
 
 
c2b283c
 
 
 
 
 
e44895f
26fc68d
e44895f
c2b283c
 
 
e44895f
c2b283c
e44895f
c2b283c
 
 
e44895f
c2b283c
e44895f
 
 
c2b283c
e44895f
c2b283c
e44895f
c2b283c
e44895f
c2b283c
 
 
 
e44895f
c2b283c
e44895f
c2b283c
 
 
 
e44895f
c2b283c
e44895f
c2b283c
 
e44895f
c2b283c
e44895f
c2b283c
 
 
e44895f
c2b283c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e44895f
 
c2b283c
e44895f
dcbef49
 
 
 
e44895f
c2b283c
e44895f
c2b283c
e44895f
c2b283c
e44895f
c2b283c
 
e44895f
 
 
c2b283c
 
e44895f
c2b283c
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
---
license: mit
metrics:
- accuracy
- precision
- recall
- f1
base_model:
- google/efficientnet-b7
pipeline_tag: image-classification
tags:
- medical
- cervical-cancer
- histopathology
- undersampling
---

# Model Card: EfficientNet-B7 for Cervical Cancer Image Classification

This model fine-tunes **EfficientNet-B7** for the task of binary cervical cancer image classification (Negative vs. Positive). It was trained using undersampling to handle class imbalance.

---

## Model Details

- **Developed by:** Beijuka / Pathogen Lab
- **Funded by:** STI
- **Model type:** Convolutional Neural Network (CNN)
- **Input type:** Histopathology images (600x600, RGB)
- **Output type:** Binary classification (Negative, Positive)
- **License:** MIT
- **Finetuned from:** `google/efficientnet-b7`

<!-- ### Model Sources
- **Repository:** [Your HF Repo URL]
- **Paper [optional]:** [If you want to link e.g., EfficientNet or related research]
- **Demo [optional]:** [Streamlit/Gradio app if you plan one]
 -->
---

## Uses

### Direct Use
- classification of cervical cancer images into Negative vs Positive cases.  

### Downstream Use
- Could be integrated into diagnostic support pipelines.  
- Adapted for related medical imaging classification tasks.

### Out-of-Scope Use
- **Not** a replacement for professional medical diagnosis.  
- Should not be deployed clinically without regulatory approval.  
- Not suitable for non-cervical images.

---

## Bias, Risks, and Limitations

- The dataset was undersampled → may affect generalizability.  
- Model performance varies by threshold (see below).  
- Limited dataset size (19 test images) means results may not generalize.  
- Potential domain shift if applied to different staining/preparation protocols.

### Recommendations
- Validate on larger, more diverse datasets.  
- Carefully calibrate decision threshold depending on application (screening vs confirmatory).  
- Use alongside clinical expertise, not as a standalone tool.

---

## How to Get Started

```python
from huggingface_hub import hf_hub_download
from tensorflow import keras

model_path = hf_hub_download(
    "Beijuka/cancer-efficientnetb7-undersampling",
    "cancer_efficientnetB7_undersampling.keras"
)
model = keras.models.load_model(model_path)
````

---

## Training Details

### Training Data

* Histopathology images of cervical cancer (size 600x600, RGB).
* Class imbalance addressed via **undersampling**:

  * Positive: 84 images
  * Negative: 100 images
* Preprocessing: Normalization + resizing.

### Training Procedure

* Optimizer: Adam
* Loss: Binary Crossentropy
* Batch size: 8
* Learning rate: 1e-3 (initial), 1e-5 (fine-tuning)
* Epochs: 50 (initial), 20 (fine-tuning)
* EarlyStopping and ModelCheckpoint callbacks used.

### Data Splits (70:20:10)

* **Training:** 128 images (70 Negative, 29 Positive Post-stained, 29 Positive Pre-stained)
* **Validation:** 37 images (20 Negative, 8 Positive Post-stained, 9 Positive Pre-stained)
* **Test:** 19 images (10 Negative, 5 Positive Post-stained, 4 Positive Pre-stained)

### Hardware

* GPU: Tesla T4 (14GB)
* CUDA Version: 12.4
* Software: TensorFlow/Keras

---

## Evaluation

### Testing Data

* Independent test set: 19 images (10 Negative, 9 Positive)

### Metrics at Threshold 0.5

* **Accuracy:** 0.7368
* **Precision (Positive):** 0.8333
* **Recall (Positive):** 0.5556
* **F1-Score (Positive):** 0.6667

#### Confusion Matrix

```
[[9, 1],
 [4, 5]]
```

#### Sensitivity / Specificity

* Negative: Sensitivity 0.90, Specificity 0.56
* Positive: Sensitivity 0.56, Specificity 0.90

### Threshold Analysis

* Best balance observed near 0.45–0.50
* Lower thresholds → higher recall, more false positives
* Higher thresholds (>0.65) → model collapses to predicting only one class

| Threshold | Accuracy | Precision | Recall | F1     |
| --------- | -------- | --------- | ------ | ------ |
| 0.00      | 0.4737   | 0.4737    | 1.0000 | 0.6429 |
| 0.05      | 0.4737   | 0.4737    | 1.0000 | 0.6429 |
| 0.10      | 0.5263   | 0.5000    | 1.0000 | 0.6667 |
| 0.15      | 0.5263   | 0.5000    | 0.8889 | 0.6400 |
| 0.20      | 0.6316   | 0.5714    | 0.8889 | 0.6957 |
| 0.25      | 0.6316   | 0.5833    | 0.7778 | 0.6667 |
| 0.30      | 0.6316   | 0.6250    | 0.5556 | 0.5882 |
| 0.35      | 0.6316   | 0.6250    | 0.5556 | 0.5882 |
| 0.40      | 0.6842   | 0.7143    | 0.5556 | 0.6250 |
| 0.45      | 0.7368   | 0.8333    | 0.5556 | 0.6667 |
| 0.50      | 0.7368   | 0.8333    | 0.5556 | 0.6667 |
| 0.55      | 0.6842   | 0.8000    | 0.4444 | 0.5714 |
| 0.60      | 0.6842   | 1.0000    | 0.3333 | 0.5000 |
| 0.65      | 0.5263   | 0.0000    | 0.0000 | 0.0000 |
| 0.70      | 0.5263   | 0.0000    | 0.0000 | 0.0000 |
| 0.75      | 0.5263   | 0.0000    | 0.0000 | 0.0000 |
| 0.80      | 0.5263   | 0.0000    | 0.0000 | 0.0000 |
| 0.85      | 0.5263   | 0.0000    | 0.0000 | 0.0000 |
| 0.90      | 0.5263   | 0.0000    | 0.0000 | 0.0000 |
| 0.95      | 0.5263   | 0.0000    | 0.0000 | 0.0000 |


### Comparison of performance on Pre vs Post-stained images

| Comparison                     | Accuracy | F1-Score | Precision |Recall |
| ------------------------------ | -------- | -------- | -------- | ------- |
| Pre-stained Prediction  | 0.6087   | 0.2703   |0.1613 |0.8333|
| Post-stained Prediction | 0.7474   | 0.3441   |0.2222 |0.7619|

---

## Technical Specifications

### Model Architecture

* EfficientNet-B7 backbone
* Final Dense layer with sigmoid activation for binary classification

### Compute Infrastructure

* **Hardware:** Tesla T4 GPU
* **Software:** TensorFlow/Keras

---