Gatekeeper β Colposcopy Image Validator
by Dawa Health
Gatekeeper is a binary image classifier that determines whether an input image is a valid colposcopy image before it is passed to CerviTriage AI. Built on a fine-tuned ResNet50 (layer3 + layer4 unfrozen), it acts as a quality control gate β rejecting non-colposcopy images to prevent spurious AI predictions.
Classes
| Class | Description |
|---|---|
cervix |
Valid colposcopy image β pass to CerviTriage AI |
not_cervix |
Invalid image β reject and prompt re-capture |
Model Architecture
| Component | Detail |
|---|---|
| Backbone | ResNet50 (layer3 + layer4 unfrozen) |
| Input size | 224 Γ 224 RGB |
| Output | 2-class softmax probabilities |
| Deployment format | ONNX (Arduino Uno Q compatible) |
Intended Use
- Primary use: Pre-screening gate before CerviTriage AI inference
- Target users: Developers integrating cervical cancer screening pipelines
- Deployment context: Dawa Health's CerviTriage edge application
Pipeline Position
Camera input
β
βΌ
Gatekeeper
β
cervix? ββNoβββΆ Reject: "Please re-capture image"
β
Yes
β
βΌ
CerviTriage AI
β
βΌ
Triage result
Quick Start
import numpy as np
from PIL import Image
from gatekeeper import preprocess, is_colposcopy, get_label, get_confidence
# Load image
image = np.array(Image.open("image.jpg").convert("RGB"))
# Preprocess β (1, 3, 224, 224) float32
input_tensor = preprocess(image)
# Run inference (ONNX example)
import onnxruntime as ort
session = ort.InferenceSession("gatekeeper.onnx")
logits = session.run(None, {"input": input_tensor})[0]
# Postprocess
if is_colposcopy(logits):
print(f"Valid colposcopy image (confidence: {get_confidence(logits):.1%})")
# β pass to CerviTriage AI
else:
print("Not a colposcopy image β please re-capture")
Preprocessing Pipeline
IMAGENET_MEAN = [0.485, 0.456, 0.406]
IMAGENET_STD = [0.229, 0.224, 0.225]
def preprocess(image):
"""Resize to 224Γ224 β ImageNet normalize β (1, 3, 224, 224) float32."""
Unit Tests and Code Coverage
The deployed ONNX model (gatekeeper_direct.onnx) is covered by an automated inference test suite using pytest and pytest-cov. Tests load the actual model file and run real inference on CPU.
| Module | Tests | Coverage |
|---|---|---|
conftest.py |
β | 100% |
test_gatekeeper_onnx.py |
20 | 100% |
| Total | 20/20 passed | 100% |
Run tests:
pip install pytest pytest-cov onnxruntime pillow numpy
pytest tests/ --cov=. --cov-report=term-missing -v
Test results (November 2026):
- β 20/20 tests passed
- β 0 failures, 0 errors
- β 100% code coverage
Tests cover: model loading, input shape (1Γ3Γ224Γ224), binary output (cervix/not_cervix), black/white/grey edge-case inference, softmax postprocessing, confidence scoring, and CPU determinism.
License
This model is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).
- You may use, modify, and distribute this model freely
- If you deploy this model as a network service, you must release your modified source code under AGPL-3.0
- For commercial or proprietary licensing: hello@dawahealth.co
SPDX-License-Identifier: AGPL-3.0-only
Citation
@misc{dawahealth2024gatekeeper,
title = {Gatekeeper: ResNet50-based Colposcopy Image Validator},
author = {Dawa Health},
year = {2024},
publisher = {HuggingFace},
howpublished = {\url{https://huggingface.co/dawahealth/gatekeeper}}
}
Contributing
See CONTRIBUTING.md for our pull request workflow, CI/CD setup, and testing guide.
Code of Conduct
See CODE_OF_CONDUCT.md. We follow the Contributor Covenant v2.1.
Contact
Dawa Health Β· hello@dawahealth.co Β· dawahealth.co