| --- |
| license: mit |
| language: |
| - en |
| base_model: |
| - facebook/dinov2-base |
| pipeline_tag: image-segmentation |
| tags: |
| - micronuclei-segmentation |
| --- |
| |
| # mnDINO: Accurate and robust segmentation of micronuclei with vision transformer networks |
| This repository provides the pre-trained mnDINO model for our paper: [mnDINO: Accurate and robust segmentation of micronuclei with vision transformer networks](https://www.biorxiv.org/content/10.64898/2026.03.09.710648v2). The official PyTorch source code is publicly available on [GitHub](https://github.com/CaicedoLab/micronuclei-detection), and the annotated micronuclei dataset can be downloaded through the [Bioimage Archive](https://www.ebi.ac.uk/biostudies/bioimages/studies/S-BIAD2809). |
|
|
| The mnDINO model is specifically designed for highly efficient and accurate micronuclei segmentation in DNA-stained images across diverse experimental conditions. The model outputs both micronuclei and nuclei segmentation masks simultaneously. To accelerate future research in micronucleus (MN) biology. The dataset, code, and pre-trained model are made publicly available to facilitate future research in micronucleus (MN) biology. |
| # Usage |
| ### Install Package |
| ```bash |
| pip install mndino |
| ``` |
|
|
| ### Load the model |
| ```python |
| import torch |
| from mndino import mnmodel |
| from huggingface_hub import hf_hub_download |
| |
| model_path = hf_hub_download(repo_id="CaicedoLab/mnDINO", filename="mnDINO_v1.pth") |
| device = "cuda" if torch.cuda.is_available() else "cpu" |
| model = mnmodel.MicronucleiModel(device=device) |
| model.load(model_path) |
| ``` |
|
|
| ### Make predictions |
| ```python |
| import skimage |
| import numpy as np |
| |
| STEP = 32 # recommended value |
| PREDICTION_BATCH = 4 |
| THRESHOLD = 0.5 |
| |
| im = skimage.io.imread(your_image_path) |
| im = np.array((im - np.min(im))/(np.max(im) - np.min(im)), dtype="float32") # normalize image |
| probabilities = model.predict(im, stride=1, step=STEP, batch_size=PREDICTION_BATCH) |
| |
| mn_predictions = probabilities[0,:,:] > THRESHOLD |
| nuclei_predictions = probabilities[1,:,:] > THRESHOLD |
| ``` |
|
|
| ### Evaluation |
| ```python |
| import skimage |
| from mndino import evaluation |
| |
| mn_gt = skimage.io.imread(your_annotated_image_path) |
| precision, recall = evaluation.segmentation_report(predictions=mn_predictions, gt=mn_gt, intersection_ratio=0.1, wandb_mode=False) |
| ``` |