Skip to main content

A plugin for segmentation by pixel classification using pre-trained neural networks for feature extraction

Project description

License PyPI Python Version tests codecov

overview conv-paint This tool, that comes both as a napari plugin and an intuitive Python API, can be used to segment objects or structures in images based on a few examples for the classes provided by the user in form of scribbles onto the image.

Following an idea similar to other tools like ilastik, its main strength lies in its capability to use features from basically any model that creates meaningful features describing an image: from neural networks like VGG16 to foundational ViTs such as DINOV2, but also popular models such as Ilastik or Cellpose. This enables the segmentation of virtually any type of image, from simple to complex - without the need of switching and learning new tools.

Find more information and tutorials in the docs, the recording of the presentation at I2K 2025 conference or read the paper.

overview conv-paint

Installation

You can install napari-convpaint via pip:

pip install napari-convpaint

Note: If you are running into an error that vispy requires a certain C++ version, you can install vispy via conda install vispy and then install napari-convpaint via pip to avoid this.

To install the latest development version:

pip install git+https://github.com/guiwitz/napari-convpaint.git

The plugin is also available on the napari plugin hub, and can be installed via the napari plugin system (Plugins>Install/Uninstall plugins..> search for napari-convpaint).

Example use case: Tracking shark body parts in a movie

These are the scribble annotations provided for training:

And this is the resulting Convpaint segmentation:

Check out the documentation or the paper for more usecases!

API

You can use the Convpaint API in a fashion very similar to the napari plugin. The ConvpaintModel class combines a feature extractor and a classifier model, and holds all the parameters defining the model.

Initialize a ConvpaintModel object, train its classifier and use it to segment an image:

cp_model = ConvpaintModel("dino") # alternatively use vgg, cellpose or gaussian
cp_model.train(image, annotations)
segmentation = cp_model.segment(image)

There are many other options, such as predicting all classes as separate probabilities (see below). Please refer to the documentation for more details.

probas = cp_model.predict_probas(image)

License

Distributed under the terms of the BSD-3 license, "napari-convpaint" is free and open source software, except for the code in the jafar/ directory, which is adapted from an Apache License 2.0–licensed project, see jafar/LICENSE.

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.

Issues

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

Authors

The idea behind this napari plugin was first developed by Lucien Hinderling in the group of Olivier Pertz, at the Institute of Cell Biology, University of Bern. Pertz lab obtained a CZI napari plugin development grant with the title "Democratizing Image Analysis with an Easy-to-Train Classifier" which supported the adaptation of the initial concept as a napari plugin called napari-convpaint. The plugin has been developed by Guillaume Witz1, Roman Schwob1,2 and Lucien Hinderling2 with much appreciated assistance of Benjamin Grädel2, Maciej Dobrzyński2, Mykhailo Vladymyrov1 and Ana Stojiljković1.

1Data Science Lab, University of Bern
2Pertz Lab, Institute of Cell Biology, University of Bern

Cite Convpaint

If you find Convpaint useful in your research, please consider citing our work. Please also cite any Feature Extractor you have used within Convpaint, such as ilastik, cellpose, DINOv2 or JAFAR.

Convpaint:

@article{Hinderling2026,
	author = {Hinderling, Lucien and Schwob, Roman and Witz, Guillaume and Stojiljković, Ana and Dobrzyński, Maciej and Vladymyrov, Mykhailo and Frei, Joël and Grädel, Benjamin and Frismantiene, Agne and Pertz, Olivier},
	title = {Convpaint—Interactive pixel classification using pretrained neural networks},
	doi = {10.1016/j.crmeth.2026.101335},
	journal = {Cell Reports Methods},
	publisher = {Elsevier BV},
	volume = {6},
	number = {3},
	pages = {101335},
	year = {2026},
	month = mar,
}

Suggested citations for feature extractors:

@article {Berg2019,
	author = {Berg, Stuart and Kutra, Dominik and Kroeger, Thorben and Straehle, Christoph N. and Kausler, Bernhard X. and Haubold, Carsten and Schiegg, Martin and Ales, Janez and Beier, Thorsten and Rudy, Markus and Eren, Kemal and Cervantes, Jaime I. and Xu, Buote and Beuttenmueller, Fynn and Wolny, Adrian and Zhang, Chong and Koethe, Ullrich and Hamprecht, Fred A. and Kreshuk, Anna},
	title = {ilastik: interactive machine learning for (bio)image analysis.},
	issn = {1548-7105},
	url = {https://doi.org/10.1038/s41592-019-0582-9},
	doi = {10.1038/s41592-019-0582-9},
	journal = {Nature Methods},
	publisher = {Springer Nature},
	year = {2019},
	journal = {Nature Methods},
}
@article {Stringer2021,
	author = {Stringer, Carsen and Wang, Tim and Michaelos, Michalis and Pachitariu Marius},
	title = {Cellpose: a generalist algorithm for cellular segmentation.},
	elocation-id = {s41592-020-01018-x},
	doi = {10.1038/s41592-020-01018-x},
	journal = {Nature Methods},
	publisher = {Springer Nature},
	year = {2021},
}
@article {oquab2024dinov2learningrobustvisual,
      title={DINOv2: Learning Robust Visual Features without Supervision}, 
      author={Maxime Oquab and Timothée Darcet and Théo Moutakanni and Huy Vo and Marc Szafraniec and Vasil Khalidov and Pierre Fernandez and Daniel Haziza and Francisco Massa and Alaaeldin El-Nouby and Mahmoud Assran and Nicolas Ballas and Wojciech Galuba and Russell Howes and Po-Yao Huang and Shang-Wen Li and Ishan Misra and Michael Rabbat and Vasu Sharma and Gabriel Synnaeve and Hu Xu and Hervé Jegou and Julien Mairal and Patrick Labatut and Armand Joulin and Piotr Bojanowski},
      year={2024},
      eprint={2304.07193},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2304.07193}
}
@misc{couairon2025jafar,
      title={JAFAR: Jack up Any Feature at Any Resolution}, 
      author={Paul Couairon and Loick Chambon and Louis Serrano and Jean-Emmanuel Haugeard and Matthieu Cord and Nicolas Thome},
      year={2025},
      eprint={2506.11136},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2506.11136}, 
}

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_convpaint-1.0.0.tar.gz (32.1 MB view details)

Uploaded Source

Built Distribution

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

napari_convpaint-1.0.0-py3-none-any.whl (441.2 kB view details)

Uploaded Python 3

File details

Details for the file napari_convpaint-1.0.0.tar.gz.

File metadata

  • Download URL: napari_convpaint-1.0.0.tar.gz
  • Upload date:
  • Size: 32.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for napari_convpaint-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6edf10d02d5563584b8ecb6cc7226d9e2d8b1999d43c952f5872935f9d7c1268
MD5 8e93a69c64f020d9134fb4d08a2ae87b
BLAKE2b-256 4e4b358503320f852f5c47e4a206eee76eb5781deee783927592aec2e9ba95ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for napari_convpaint-1.0.0.tar.gz:

Publisher: test_and_deploy.yml on guiwitz/napari-convpaint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file napari_convpaint-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for napari_convpaint-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eeae0d99feab1d7a11c4438b7d47fc32c91b3594a6fe5d1410f13d87cf3166eb
MD5 7b82de03b8af39017cbec282d1517391
BLAKE2b-256 1e84fdaf1acf67ed5ca051d2f30e3bb170d6bb7453eb997354014487a1234d6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for napari_convpaint-1.0.0-py3-none-any.whl:

Publisher: test_and_deploy.yml on guiwitz/napari-convpaint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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