Skip to main content

A simple plugin to use DinoSim in napari

Project description

DINOSim

License MIT biorxiv PyPI Python Version tests codecov napari hub

DINOSim-simple

Description

This repository provides DINOSim, a method that leverages the DINOv2 foundation model for zero-shot object detection and segmentation in bioimage analysis. DINOSim uses pretrained DINOv2 embeddings to compare patch similarities, allowing it to detect and segment unseen objects in complex datasets with minimal annotations.

The DINOSim Napari plugin offers a user-friendly interface that simplifies bioimage analysis workflows, making it an adaptable solution for object detection across scientific research fields with limited labeled data.

Note: The current version of the plugin generates segmentation masks based on object similarity.

Usage

To use the plugin, you only need to load an image and click in the object you want to segment, automatically a mask will be generated. Multiple prompts for the same object are allowed.

Documentation

There are few parameters that you can modify to improve the segmentation results:

  • Model size: This parameter controls the size of the DINOv2 model used. Larger models are more accurate but also require more memory and processing power. Once you have selected the model size, you need to click in Load New Model button to apply the changes. The button will indicate the model that is being used. By default, the pluggin will use the smallest model.
  • Threshold: This parameter controls the minimum similarity score between the query patch and the reference patches. Adjusting this value allows you to control the sensitivity of the segmentation. Higher values make the segmentation more strict, while lower values make it more permissive.
  • Patch size: This parameter controls the size of the patches used for segmentation. Adjusting this value allows you to control the granularity of the segmentation. Smaller values make the segmentation more detailed, while larger values make it more coarse.

Using GPU acceleration is recommended for faster processing. If its available, the plugin will use it automatically. To check if your GPU is being used, you can check the GPU status tab in the napari viewer.

If multiple images are loaded, you need to specify which one is the prompted, using the Image layer. Once you have the prompted image, you can find all object in all other images by using Process All Images button.

If you want to reset the threshold and process the reference image again, you can use the Reset button. This might be useful if you changed the Image layer and the model has not been applied automatically.

By default, the plugin will add a annotation layer, but if you remove it or add more than one, only the last one will be used. Until you do not prompt in the anotation layer with one loaded image, the pluggin will not give any output.

Example

One notebook example is provided in the repository to show how to use DINOSim directly through python, without napari.


This napari plugin was generated with Cookiecutter using @napari's cookiecutter-napari-plugin template.

Installation

You can install napari-dinoSim either via pip:

pip install napari-dinosim

or from source via conda:

# Clone the repository
git clone https://github.com/AAitorG/napari-dinoSim.git
cd napari-dinoSim

# Create and activate the conda environment
conda env create -f environment.yml
conda activate napari-dinosim

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the MIT license, "napari-dinoSim" is free and open source software

Citation

If you use DINOSim in your research, please use the following BibTex:

@article {Gonzalez-Marfil2025dinosim,
	title = {DINOSim: Zero-Shot Object Detection and Semantic Segmentation on Electron Microscopy Images},
	author = {Gonz{\'a}lez-Marfil, Aitor and G{\'o}mez-de-Mariscal, Estibaliz and Arganda-Carreras, Ignacio},
	journal = {bioRxiv}
	publisher = {Cold Spring Harbor Laboratory},
	url = {https://www.biorxiv.org/content/early/2025/03/13/2025.03.09.642092},
	doi = {10.1101/2025.03.09.642092},
	year = {2025},
}

Issues

If you encounter any problems, please [file an issue] along with a detailed description.

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

napari_dinosim-0.0.7.tar.gz (31.5 kB view details)

Uploaded Source

Built Distribution

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

napari_dinosim-0.0.7-py3-none-any.whl (30.0 kB view details)

Uploaded Python 3

File details

Details for the file napari_dinosim-0.0.7.tar.gz.

File metadata

  • Download URL: napari_dinosim-0.0.7.tar.gz
  • Upload date:
  • Size: 31.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for napari_dinosim-0.0.7.tar.gz
Algorithm Hash digest
SHA256 e9e7ebce857f0a01d03a94f4fce7e3ef378b0ed620168227cb219df2bb68562e
MD5 29f3af27b8466eda07a75d70e0755bb4
BLAKE2b-256 7d55946e66f9c2cdc2abe457d3edb0444b99ef8f0539acb7c4004c897fceeaf8

See more details on using hashes here.

File details

Details for the file napari_dinosim-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: napari_dinosim-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 30.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for napari_dinosim-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e8080fb1459681db85e254061c45b4cecb0ebadc00b6f1f19cdca99aad5fa009
MD5 de7d7daeda8cd58199dbee92152e704c
BLAKE2b-256 76178654ba27d6235bf27dfe18fe1ac1cf2f4e59aa245cf1cd6bf9217464a42e

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