Skip to main content

Cervical colour segmentation with DINOv3, DPT, and WTConv

Project description

CervicalSeg

Inference-only cervical colour segmentation using DINOv3 ViT-S/16, DPT, and WTConv.

Classes are background, blue, green, and red. This package is intended for research use and is not a clinical diagnostic device.

The package supports both DINOv3 state-dict layouts used by Transformers 4.56+ and 5.x.

Local installation

pip install -e .

The source checkout automatically finds weights/model.safetensors. After the public release, an installed wheel downloads the versioned weights from PlanetSMH/CervicalSeg automatically. A local weights file can also be selected explicitly:

from cervicalseg import CervicalSeg

segmenter = CervicalSeg(weights_path="/path/to/model.safetensors")
result = segmenter.predict("image.jpg")

result.save_mask("mask.png")
result.save_color_mask("color_mask.png")
result.save_overlay("overlay.jpg")

result.mask is an H x W uint8 NumPy array restored to the original image size. Class indices are 0=background, 1=blue, 2=green, and 3=red.

Batch inference

results = segmenter.predict_batch(
    ["a.jpg", "b.jpg"],
    batch_size=2,
    return_probabilities=False,
)

Input may be a path, a PIL RGB image, or an H x W x 3 RGB NumPy array. Set return_probabilities=True to populate result.probabilities with a 4 x H x W float32 array.

Command line

cervicalseg image1.jpg image2.jpg \
  --weights /path/to/model.safetensors \
  --output results

Hugging Face weights

Published weights are downloaded automatically and pinned to the package version:

segmenter = CervicalSeg()

# Explicit repository selection is also supported.
segmenter = CervicalSeg(repo_id="PlanetSMH/CervicalSeg", revision="v0.1.0")

Downloaded assets are cached by huggingface_hub. CERVICALSEG_WEIGHTS may be set to a local weights path for offline use.

Build the package

python -m build
python -m twine check dist/*

The Python distributions contain inference code and license notices only. Model weights are published separately on Hugging Face Hub.

Third-party notices

The trained weights contain DINOv3 materials distributed under the DINOv3 License. WTConv-derived code is used under the MIT License. Copies are provided in licenses/.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cervicalseg-0.1.1.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cervicalseg-0.1.1-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file cervicalseg-0.1.1.tar.gz.

File metadata

  • Download URL: cervicalseg-0.1.1.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for cervicalseg-0.1.1.tar.gz
Algorithm Hash digest
SHA256 eaa080e480e024aed9193d9e8ab7c66d56869ae4eaa614cc3344696d15646025
MD5 e3aaf8b65a5ce7fbba87af8abadc24e5
BLAKE2b-256 f6e64aef83963bc94386e1ba7416cbf14b3d63113eb7fbd29c68479cd197b59e

See more details on using hashes here.

File details

Details for the file cervicalseg-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cervicalseg-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for cervicalseg-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 38bf9deebf39a49d87cf4b10dbead073e054f0fdf8a5045ffea0882045516294
MD5 608103a2a3b76d0267fa678014a6e27f
BLAKE2b-256 a2fc0695d364c4e23f55129cbe26a8d018bd8f29959038fbae28f714ba5dfe11

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page