Beijuka's picture
Update README.md
26fc68d verified
---
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
---