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. The official PyTorch source code is publicly available on GitHub, and the annotated micronuclei dataset can be downloaded through the Bioimage Archive.
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
pip install mndino
Load the model
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
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
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)
Model tree for CaicedoLab/mnDINO
Base model
facebook/dinov2-base