Metadata-Version: 2.4
Name: napari-dinosim
Version: 0.1.7
Summary: A simple plugin to use DINOSim in napari
Author: Aitor Gonzalez-Marfil
Author-email: aitorgacad@gmail.com
License: MIT License
        
        Copyright (c) 2025 Aitor González-Marfil
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Documentation, https://github.com/AAitorG/napari-DINOSim#readme
Project-URL: Repository, https://github.com/AAitorG/napari-DINOSim
Project-URL: Issues, https://github.com/AAitorG/napari-DINOSim/issues
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: napari
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Image Processing
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: <3.14,>=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.21.0
Requires-Dist: magicgui>=0.5.0
Requires-Dist: qtpy
Requires-Dist: torch>=2.0.0
Requires-Dist: torchvision>=0.15.0
Requires-Dist: tqdm>=4.62.0
Requires-Dist: pillow>=9.0.0
Requires-Dist: matplotlib>=3.5.0
Requires-Dist: opencv-python
Requires-Dist: tifffile
Requires-Dist: napari
Provides-Extra: all
Requires-Dist: napari[all]; extra == "all"
Provides-Extra: testing
Requires-Dist: tox; extra == "testing"
Requires-Dist: pytest>=8.3.5; extra == "testing"
Requires-Dist: pytest-qt>=4.4.0; extra == "testing"
Requires-Dist: pytest-xvfb>=3.0.0; extra == "testing"
Requires-Dist: pytest-cov>=6.0; extra == "testing"
Requires-Dist: pyqt5>=5.15.11; python_version < "3.11" and extra == "testing"
Requires-Dist: PyQt6>=6.7; python_version >= "3.11" and extra == "testing"
Provides-Extra: dev
Requires-Dist: black; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Dynamic: license-file

# DINOSim

[![License: MIT](https://img.shields.io/pypi/l/napari-dinosim.svg?color=blue)](https://github.com/AAitorG/napari-DINOSim/raw/main/LICENSE)
[![DOI](https://img.shields.io/badge/DOI-10.1002%2Fjemt.70194-bd2635)](https://doi.org/10.1002/jemt.70194)
[![PyPI](https://img.shields.io/pypi/v/napari-DINOSim.svg?color=green)](https://pypi.org/project/napari-DINOSim)
[![Python Version](https://img.shields.io/pypi/pyversions/napari-DINOSim.svg?color=green)](https://python.org)
[![tests](https://github.com/AAitorG/napari-DINOSim/workflows/tests/badge.svg)](https://github.com/AAitorG/napari-DINOSim/actions)
[![napari hub](https://img.shields.io/endpoint?url=https://api.napari-hub.org/shields/napari-dinosim)](https://napari-hub.org/plugins/napari-dinosim)

![DINOSim-simple](docs/DINOSim-simplest.png)

A [napari] plugin for zero-shot image segmentation using DINOv2 vision transformers.

----------------------------------

## Overview

`napari-DINOSim` enables zero-shot image segmentation by selecting reference points on an image. The plugin leverages DINOv2's powerful feature extraction capabilities to compute similarity maps and generate segmentation masks.

For detailed information about the widget's functionality, UI elements, and usage instructions, please refer to the [Plugin Documentation](./docs/plugin_documentation.md). A simple [example notebook](./src/DINOSim_example.ipynb) and an [advanced notebook](./src/DINOSim_advanced.ipynb) are also available for programmatic use, showing how to load/save embeddings and references.

## Installation

For a fresh environment, install `napari-DINOSim` with napari:

```sh
pip install "napari-dinosim[all]"
```

When napari is already installed, including through the napari plugin manager, install only the plugin:

```sh
pip install napari-dinosim
```

To install from source with [conda]:

```bash
# 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
```

**Note on GPU/CUDA Compatibility:**
The runtime will automatically fall back to CPU or Apple MPS if CUDA is unavailable. However, environment installation (e.g., via `conda` or `pip`) may still fail or produce runtime errors on older systems if the installed PyTorch wheel targets an incompatible CUDA version. If you experience GPU-related installation errors, please reinstall PyTorch with a matching CUDA build or opt for the CPU-only version from the [official PyTorch guide](https://pytorch.org/get-started/locally/).

## Usage

To launch napari, run the following command in your terminal:

```sh
napari
```

Within the napari interface, go to `Plugins` > `DINOSim Segmentation` > `DINOSim Widget` in the menu bar. You can then:
1. Drag and drop your image into the napari viewer
2. Select points on the objects you want to segment
3. The plugin will automatically generate segmentation masks based on your selections

For more detailed instructions and examples, please refer to our [Plugin Documentation](./docs/plugin_documentation.md).

## License and contributing

The code is distributed under the [MIT](https://opensource.org/licenses/MIT) license. Contributions are welcome. Please [open an issue](https://github.com/AAitorG/napari-DINOSim/issues) if you run into a problem.

## Citation

Please note that DINOSim is based on a [publication](https://doi.org/10.1002/jemt.70194). If you use DINOSim in your research, please be so kind to cite our work:

```bibtex
@article{Gonzalez-Marfil2026dinosim,
    author = {González-Marfil, Aitor and Gómez-de-Mariscal, Estibaliz and Arganda-Carreras, Ignacio},
    title = {DINOSim: Training-Free Semantic Segmentation on Microscopy Images},
    journal = {Microscopy Research and Technique},
    year = {2026},
    doi = {https://doi.org/10.1002/jemt.70194},
}
```

[napari]: https://github.com/napari/napari
[MIT]: http://opensource.org/licenses/MIT
[pip]: https://pypi.org/project/pip/
[conda]: https://docs.conda.io/en/latest/miniconda.html
