CerviTriage AI — MedSigLIP Diagnosis Model
Dawa Health Research and Innovation Team
Licence: Dawa Health's work is offered under AGPL-3.0. The model is built on Google's MedSigLIP and is also subject to the Health AI Developer Foundations Terms of Use. Not a medical device. Research and internal validation use only. See Licence and Terms below.
Overview
CerviTriage AI classifies colposcopy images of the cervix into five categories: Normal, CIN1, CIN2, CIN3 and Cancer. It is built for cervical cancer screening at the point of care in settings where no colposcopist is available, and is designed to run offline on an edge device.
The model is a small classifier head trained on top of a frozen MedSigLIP image encoder from Google.
In the CerviTriage pipeline it runs after a gatekeeper model, which rejects images that are not colposcopy images:
colposcope → Dawa Clinician app → edge device
→ gatekeeper (is this a colposcopy image?)
→ this model (five-class result)
→ result returned to the app for review by the clinician
Classes
| Class | Dataset folder | Clinical meaning |
|---|---|---|
| Normal | Negative | No abnormality detected |
| CIN1 | CIN1 | Mild dysplasia, low risk |
| CIN2 | CIN2 | Moderate dysplasia, mid risk |
| CIN3 | CIN3 | Severe dysplasia, high risk |
| Cancer | Positive | Invasive cancer |
[TO CONFIRM: the output index of each class, from app.py.]
Model Details
| Item | Value |
|---|---|
| Task | Image classification, five classes |
| Backbone | MedSigLIP image encoder (google/medsiglip-448), fully frozen |
| Classifier head | Three linear layers, about 725,000 trainable parameters |
| Total parameters | About 400 million |
| Framework | Hugging Face Transformers / PyTorch; ONNX for deployment |
| Input | RGB colposcopy image. [TO CONFIRM: input resolution; the base model takes 448 × 448.] |
| Developed by | Khanyi Tapiwa Magagula, Dawa Health |
Classifier head:
Input (1152-dim MedSigLIP pooled image features)
→ Linear(1152 → 512) → BatchNorm → ReLU → Dropout(0.4)
→ Linear(512 → 256) → BatchNorm → ReLU → Dropout(0.3)
→ Linear(256 → 5)
MedSigLIP was chosen over general-purpose ImageNet models because it was pre-trained on medical images. The backbone was kept frozen so that a model of this size would not overfit a small dataset.
Files
| File | Size | Description |
|---|---|---|
| model.safetensors | 3.51 GB | MedSigLIP backbone weights |
| classifier_best.pt | 2.91 MB | Trained classifier head (PyTorch) |
| medsiglip_direct.onnx | 1.64 GB | Full model, backbone and head, float32, as deployed |
| gatekeeper_best.pt | 96.5 MB | Gatekeeper model, earlier version (PyTorch) |
| gatekeeper_direct.onnx | 91.6 MB | Gatekeeper model, as deployed |
| app.py | Reference inference script |
The current gatekeeper is published separately at dawahealth/best_gatekeeper_v2.
Usage
app.py in this repository is the reference inference script. The sketch below shows how the two parts fit together.
import torch
import torch.nn as nn
from PIL import Image
from transformers import AutoModel, AutoProcessor
from huggingface_hub import hf_hub_download
REPO_ID = "dawahealth/medsiglip-diagnosis"
BACKBONE = "google/medsiglip-448" # requires accepting Google's terms
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Frozen MedSigLIP backbone
processor = AutoProcessor.from_pretrained(BACKBONE)
backbone = AutoModel.from_pretrained(BACKBONE).to(DEVICE).eval()
# Trained classifier head
head = nn.Sequential(
nn.Linear(1152, 512), nn.BatchNorm1d(512), nn.ReLU(), nn.Dropout(0.4),
nn.Linear(512, 256), nn.BatchNorm1d(256), nn.ReLU(), nn.Dropout(0.3),
nn.Linear(256, 5)
).to(DEVICE)
head.load_state_dict(
torch.load(hf_hub_download(REPO_ID, "classifier_best.pt"),
map_location=DEVICE, weights_only=True)
)
head.eval()
image = Image.open("path/to/colposcopy_image.jpg").convert("RGB")
inputs = processor(images=image, return_tensors="pt").to(DEVICE)
with torch.no_grad():
features = backbone.vision_model(**inputs).pooler_output
probs = torch.softmax(head(features), dim=1)[0]
print(probs) # map indices to classes using the order in app.py
[TO CONFIRM: this sketch against app.py, in particular the class order and the layout of classifier_best.pt. It has not been tested against the repository.]
Training Data
| Item | Value |
|---|---|
| Source | Kaggle dataset kudzie7/medsig-cervical-cancer |
| Total images | 5,543 |
| Labelling | Expert colposcopic visual assessment by qualified clinicians |
| Split | Stratified 70% / 15% / 15%, seed 42 |
| Train / validation / test | 3,881 / 830 / 832 images |
| Class | Images |
|---|---|
| Normal | 1,445 |
| CIN1 | 954 |
| CIN2 | 980 |
| CIN3 | 992 |
| Cancer | 1,172 |
A later inspection of the dataset (October 2026) found two images in CIN2 that were exact duplicates of two others. They were present in the data this model was trained on. A cleaned set of 5,541 images has been prepared for future training.
[TO CONFIRM: the original source of the images, the consent and ethics approval under which they were collected, and the licence of the dataset.]
Training Procedure
Image features were extracted once from the frozen backbone and cached. Only the classifier head was trained on them.
| Setting | Value |
|---|---|
| Optimiser | Adam, learning rate 1e-3, weight decay 1e-4 |
| Loss | Cross-entropy with class-balanced weights |
| Sampling | Weighted random sampler, balanced across the five classes |
| Learning-rate schedule | ReduceLROnPlateau, patience 3, factor 0.5 |
| Early stopping | Patience 15 epochs, maximum 100 epochs |
| Batch size | 256 |
| Gradient clipping | Maximum norm 1.0 |
| Training augmentation | Random flips, rotation up to 15°, colour jitter |
| Hardware | NVIDIA T4 / P100 GPU on Kaggle |
Evaluation
Read this first. The figures below are probably higher than the model's real-world performance. The dataset contains many augmented copies (flipped, noisy, rotated) of a smaller set of original images, and the split was made image by image, not by original case. Copies of the same original are therefore likely to appear in both the training and the test set. These results have not been confirmed on a test set grouped by case, or on data from another site.
Results on the held-out test set of 832 images:
| Metric | Score |
|---|---|
| Accuracy | 99.52% (95% CI 98.77% – 99.81%) |
| Macro AUC | 1.0000 |
| Macro sensitivity | 99.6% |
| Macro specificity | 99.8% |
| Weighted F1 | 99.52% |
| Class | Precision | Recall | F1 | AUC |
|---|---|---|---|---|
| Normal | 99.08% | 99.08% | 99.08% | 0.9999 |
| CIN1 | 100% | 100% | 100% | 1.0000 |
| CIN2 | 100% | 100% | 100% | 1.0000 |
| CIN3 | 100% | 100% | 100% | 1.0000 |
| Cancer | 98.86% | 98.86% | 98.86% | 0.9999 |
Accuracy was 99.95% on the training set and 100.00% on the validation set.
Errors. Four of the 832 test images were misclassified: two Normal images were classed as Cancer, and two Cancer images were classed as Normal. There were no errors between neighbouring grades.
Comparison with other backbones. The same classifier head, splits and settings were used with five general-purpose models:
| Backbone | Pre-training | Test accuracy | Macro F1 |
|---|---|---|---|
| MedSigLIP (this model) | Biomedical images | 99.52% | 99.59% |
| ViT-Base/16 | ImageNet | 97.24% | 97.60% |
| EfficientNet-B0 | ImageNet | 96.75% | 97.10% |
| DINOv2 ViT-S/14 | LVD-142M | 96.39% | 96.68% |
| ResNet50 | ImageNet | 93.03% | 93.59% |
| YOLOv8s-cls | ImageNet | 91.59% | 92.03% |
Deployment
The model is exported directly from PyTorch to ONNX at full float32 precision and runs offline on an Arduino Uno Q (quad-core Arm Cortex-A53, 4 GB RAM) with ONNX Runtime on CPU. Inference takes about one minute per image.
When exporting or converting this model, check the raw output scores across several images before using the result. An earlier conversion to TFLite silently dropped the classifier head and returned the same class for every image.
Unit Tests and Code Coverage
The deployed ONNX model (medsiglip_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_cervitriage_onnx.py | 19 | 100% |
| Total | 19/19 passed | 100% |
Run the tests:
pip install pytest pytest-cov onnxruntime pillow numpy
pytest tests/ --cov=. --cov-report=term-missing -v
Test results (November 2026):
- ✅ 19/19 tests passed
- ✅ 0 failures, 0 errors
- ✅ 100% code coverage
Tests cover: model loading, input/output shape validation (1×3×448×448 → 1×5), finite output check, black/white edge-case inference, 5-class softmax postprocessing, label prediction, confidence scoring, and CPU determinism.
Limitations
- Test results likely overstated. See the note under Evaluation.
- Labels are not confirmed by histopathology. They come from visual assessment by clinicians. Histopathology is the reference standard for these diagnoses.
- Cancer can be read as Normal. Two of the four test errors were Cancer images classed as Normal, which is the most harmful error a screening tool can make.
- Single data collection. Performance across other clinical sites, devices and patient populations has not been validated.
- No external validation. The results have not been reproduced on an independent, multi-site dataset.
- Gatekeeper not yet on the device. The gatekeeper is trained but not yet integrated on the edge device, so the classifier will give a result for any image it is shown.
- Speed. About one minute per image on the edge device.
Licence and Terms
Copyright (C) 2026 Dawa Health.
This model has two layers of terms, and both apply.
1. Dawa Health's work. Dawa Health's contributions (the classifier head, its training, and the code in this repository) are offered under the GNU Affero General Public License, version 3 (AGPL-3.0-only), as published by the Free Software Foundation, to the extent Dawa Health holds the rights to do so. The full text is in the LICENSE file and at https://www.gnu.org/licenses/agpl-3.0.html.
2. The base model. This repository includes the MedSigLIP backbone weights, which Google provides under the Health AI Developer Foundations (HAI-DEF) Terms of Use. Those terms, and the HAI-DEF Prohibited Use Policy, continue to apply to the backbone, to the combined model, and to anything built from them:
- Terms of Use: https://developers.google.com/health-ai-developer-foundations/terms
- Prohibited Use Policy: https://developers.google.com/health-ai-developer-foundations/prohibited-use-policy
The notice those terms require is in the Notice file in this repository. Where the two sets of terms differ, you must comply with the HAI-DEF terms.
What this means for you
| You want to | You may | You must |
|---|---|---|
| Run or study the model | Yes | Accept the HAI-DEF terms and keep all notices |
| Share the model unchanged | Yes | Include the LICENSE and Notice files and pass on the HAI-DEF terms |
| Modify or retrain it | Yes | Release your modified version, including weights and source, under the same terms |
| Build it into a product or service, including one accessed over a network | Yes | Make the complete corresponding source of that work available to its users, and follow the HAI-DEF terms and Prohibited Use Policy |
| Keep your product closed-source | Not under this licence | Contact Dawa Health about a separate licence (see below) |
Training-data notice
The licences above do not change the terms of the dataset the model was trained on. See Training Data.
Contributions
Dawa Health maintains the official version of this model and decides what is included in it.
- Contact Dawa Health before starting work on a contribution: developers@dawa-health.com.
- Contributions are accepted only from contributors who have signed the Dawa Health Contributor Licence Agreement.
- Pull requests opened without prior agreement may be closed without review.
- Anyone may modify their own copy within the terms above. Modified versions must be clearly marked as changed and must not be presented as the official release.
For the full contributing guide including PR workflow, CI/CD pipeline, and testing standards, see CONTRIBUTING.md.
Other licensing
Organisations that cannot meet the AGPL-3.0 obligations can ask Dawa Health about a separate licence for Dawa Health's work: developers@dawa-health.com. Dawa Health cannot waive the HAI-DEF terms, which are Google's.
Names and marks
"CerviTriage" and "Dawa Health" are names of Dawa Health. The licence does not grant permission to use them to name, endorse or promote a modified version or a derived product, other than to state accurately that the work is based on this model. "MedSigLIP" is a name of Google and is used here only to identify the base model. This model is not produced or endorsed by Google.
Medical disclaimer
This model is a research prototype. The project is registered with the National Health Research Authority (NHRA) of Zambia; approval as a diagnostic device is pending. It is not an approved medical device and must not be used on its own to diagnose, treat or make decisions about the care of any person. Every result must be reviewed by a trained clinician. Its output is not a substitute for colposcopy by a trained clinician, for cytology or HPV testing, or for histological diagnosis.
No warranty. This model is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
Citation
@misc{cervitriage_medsiglip_diagnosis,
title = {CerviTriage AI: MedSigLIP Diagnosis Model},
author = {{Dawa Health Research and Innovation Team}},
year = {2026},
url = {https://huggingface.co/dawahealth/medsiglip-diagnosis}
}
Acknowledgements
- Khanyisile Tapiwa Magagula — model development
- Dawa Health Research and Innovation Team
- Google Research Team (HAI-DEF programme) — technical support
- University Teaching Hospital (UTH), Zambia — clinical partnership
- National Health Research Authority (NHRA), Zambia
- UNICEF Femtech Ventures
- Grand Challenges Canada
- TogetHER for Health (Panorama Global)