Downloads · 30 days
12
26% of all-time downloads
toderian/cerviguard_transfer_zones
cerviguard_transfer_zones is a image classification model from toderian. Use it when you need a label for an image. It is set up for pytorch. The card lists the license as mit.
This model classifies cervical images into 3 transformation zone types, which is important for colposcopy evaluation and cervical cancer screening.
Downloads · 30 days
12
26% of all-time downloads
All-time downloads
46
Public
Parameters
489K
19.9 MB on disk
Likes
0
Public
Click a slice to open those files.
.pth16 MB · 80%
From the Hugging Face model README
This model classifies cervical images into 3 transformation zone types, which is important for colposcopy evaluation and cervical cancer screening.
| Label | Type | Description |
|---|---|---|
| 0 | Type 1 | Transformation zone fully visible on ectocervix |
| 1 | Type 2 | Transformation zone partially visible (extends into endocervical canal) |
| 2 | Type 3 | Transformation zone not visible (entirely within endocervical canal) |
BaseCNN - A simple convolutional neural network with 4 conv blocks and 2 fully connected layers.
┌─────────────────────────────────────────────────────────────┐
│ INPUT (256×256×3) │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────┐
│ CONV BLOCK 1 │
│ Conv2d(3→32, 3×3) → BatchNorm2d → ReLU → MaxPool2d(2×2) │
│ Output: 128×128×32 │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────┐
│ CONV BLOCK 2 │
│ Conv2d(32→64, 3×3) → BatchNorm2d → ReLU → MaxPool2d(2×2) │
│ Output: 64×64×64 │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────┐
│ CONV BLOCK 3 │
│ Conv2d(64→128, 3×3) → BatchNorm2d → ReLU → MaxPool2d(2×2) │
│ Output: 32×32×128 │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────┐
│ CONV BLOCK 4 │
│ Conv2d(128→256, 3×3) → BatchNorm2d → ReLU → MaxPool2d(2×2)│
│ Output: 16×16×256 │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────┐
│ GLOBAL POOLING │
│ AdaptiveAvgPool2d(1×1) │
│ Output: 1×1×256 → Flatten → 256 │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────┐
│ FC BLOCK 1 │
│ Linear(256→256) → ReLU → Dropout(0.4) │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────┐
│ FC BLOCK 2 │
│ Linear(256→128) → ReLU → Dropout(0.4) │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────┐
│ CLASSIFIER │
│ Linear(128→3) │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────┐
│ OUTPUT (3 logits) │
│ [Type 1, Type 2, Type 3] │
└─────────────────────────────────────────────────────────────┘
| Layer | Type | In Channels | Out Channels | Kernel | Output Size |
|---|---|---|---|---|---|
| conv_layers.0 | Conv2d | 3 | 32 | 3×3 | 256×256×32 |
| conv_layers.1 | BatchNorm2d | 32 | 32 | - | 256×256×32 |
| conv_layers.2 | ReLU | - | - | - | 256×256×32 |
| conv_layers.3 | MaxPool2d | - | - | 2×2 | 128×128×32 |
| conv_layers.4 | Conv2d | 32 | 64 | 3×3 | 128×128×64 |
| conv_layers.5 | BatchNorm2d | 64 | 64 | - | 128×128×64 |
| conv_layers.6 | ReLU | - | - | - | 128×128×64 |
| conv_layers.7 | MaxPool2d | - | - | 2×2 | 64×64×64 |
| conv_layers.8 | Conv2d | 64 | 128 | 3×3 | 64×64×128 |
| conv_layers.9 | BatchNorm2d | 128 | 128 | - | 64×64×128 |
| conv_layers.10 | ReLU | - | - | - | 64×64×128 |
| conv_layers.11 | MaxPool2d | - | - | 2×2 | 32×32×128 |
| conv_layers.12 | Conv2d | 128 | 256 | 3×3 | 32×32×256 |
| conv_layers.13 | BatchNorm2d | 256 | 256 | - | 32×32×256 |
| conv_layers.14 | ReLU | - | - | - | 32×32×256 |
| conv_layers.15 | MaxPool2d | - | - | 2×2 | 16×16×256 |
| adaptive_pool | AdaptiveAvgPool2d | - | - | - | 1×1×256 |
| fc_layers.0 | Linear | 256 | 256 | - | 256 |
| fc_layers.1 | ReLU | - | - | - | 256 |
| fc_layers.2 | Dropout | - | - | p=0.4 | 256 |
| fc_layers.3 | Linear | 256 | 128 | - | 128 |
| fc_layers.4 | ReLU | - | - | - | 128 |
| fc_layers.5 | Dropout | - | - | p=0.4 | 128 |
| classifier | Linear | 128 | 3 | - | 3 |
| Property | Value |
|---|---|
| Total Parameters | 488,451 |
| Trainable Parameters | 488,451 |
| Input Size | (B, 3, 256, 256) |
| Output Size | (B, 3) |
| Model Size | ~1.9 MB |
| Parameter | Value |
|---|---|
| Learning Rate | 1e-4 |
| Batch Size | 32 |
| Dropout | 0.4 |
| Optimizer | Adam |
| Loss Function | CrossEntropyLoss |
| Epochs | 50 |
| Best Epoch | 41 |
| Metric | Value |
|---|---|
| Validation Accuracy | 61.69% |
| Macro F1 Score | 61.81% |
| Type | Precision | Recall | F1 Score |
|---|---|---|---|
| Type 1 | - | - | 68.32% |
| Type 2 | - | - | 56.41% |
| Type 3 | - | - | 60.69% |
pip install torch torchvision safetensors huggingface_hub
import torch
from PIL import Image
from torchvision import transforms
# Load model
from model import BaseCNN
model = BaseCNN.from_pretrained("./")
model.eval()
# Preprocess image
transform = transforms.Compose([
transforms.Resize((256, 256)),
transforms.ToTensor(),
])
image = Image.open("cervical_image.jpg").convert("RGB")
input_tensor = transform(image).unsqueeze(0)
# Inference
with torch.no_grad():
output = model(input_tensor)
probabilities = torch.softmax(output, dim=1)
prediction = output.argmax(dim=1).item()
labels = ["Type 1", "Type 2", "Type 3"]
print(f"Prediction: {labels[prediction]}")
print(f"Confidence: {probabilities[0][prediction]:.2%}")
from huggingface_hub import hf_hub_download
from safetensors.torch import load_file
import torch
import json
import importlib.util
# Download files
repo_id = "toderian/cerviguard_transfer_zones"
model_weights = hf_hub_download(repo_id, "model.safetensors")
config_file = hf_hub_download(repo_id, "config.json")
model_file = hf_hub_download(repo_id, "model.py")
# Load model class dynamically
spec = importlib.util.spec_from_file_location("model", model_file)
model_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(model_module)
# Load config and create model
with open(config_file) as f:
config = json.load(f)
model = model_module.BaseCNN(**config['model_config'])
model.load_state_dict(load_file(model_weights))
model.eval()
# Now use model for inference
| File | Description |
|---|---|
model.safetensors | Model weights (SafeTensors format, recommended) |
pytorch_model.bin | Model weights (PyTorch format, backup) |
config.json | Model architecture configuration |
model.py | Model class definition (BaseCNN) |
preprocessor_config.json | Image preprocessing configuration |
README.md | This model card |
transformers.AutoModel@misc{cerviguard-transfer-zones,
title={CerviGuard Cervical Transformation Zone Classifier},
author={toderian},
year={2026},
howpublished={\url{https://huggingface.co/toderian/cerviguard_transfer_zones}}
}
MIT License