Skip to main content

A simple plugin to use DinoSim in napari

Project description

DINOSim

License MIT PyPI Python Version tests codecov napari hub

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

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.6.tar.gz (28.6 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.6-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for napari_dinosim-0.0.6.tar.gz
Algorithm Hash digest
SHA256 21bec0a65d79b50bad3e832c58dbfb430473e08c0843368743011d63eb257751
MD5 f8a22cf6f68bd605f0c71e600cc7ae58
BLAKE2b-256 2f8bd0ff31f53caf6769936ee582f2c9985d8b9bbb10623a28a2bee376d1e515

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for napari_dinosim-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4601ae3567e460b8a80a29e0d05c878ad0802bbfbed13986374a01e46c342c79
MD5 a56a53f18b1e96a8ddcbf87aa5e72324
BLAKE2b-256 e8f0d316206e9a6f1a32e9d8c7d6a808bf1334f9512f94328fb5ec180a265532

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