Skip to main content

EPFL Center for Imaging logo

napari-rembg

Segment images using a collection of fast and lightweight generalist segmentation models in Napari. This plugin is based on the rembg project.

demo

Key features

  • Choose among five generalist segmentation models, including SAM (Segment Anything Model).
  • Quickly annotate individual objects by drawing bounding boxes around them.
  • Possibility to generate predictions via a remote web API and keep the installation lightweight on client machines.
  • Compatible with 2D, RGB, 2D+t, and 3D images (slice by slice).

Installation

You can install napari-rembg via pip. If you wish to use your local machine for the predictions (most users):

pip install "napari-rembg[local]"

If you wish to generate predictions from a web api, go for a minimal install:

pip install napari-rembg

Models

  • u2net: A pre-trained model for general use cases.
  • u2netp: A lightweight version of u2net.
  • silueta: Same as u2net with a size reduced to 43 Mb.
  • isnet: A pre-trained model for general use cases.
  • sam: Segment Anything Model pre-trained for any use cases (vit_b)

models

The models automatically get downloaded in the user's home folder in the .u2net directory the first time inference is run.

Usage

Start napari-rembg from the Plugins menu of Napari:

Plugins > Napari Select Foreground > Select foreground

Segment an image loaded into Napari

Select your image in the Image dropdown and press Run. The output segmentation appears in the Labels layer selected in the Mask field (if no layer is selected, a new one is created).

Segment individual objects using bounding boxes

  • Click on the Add button next to the ROI field. This adds a Shapes layer to the viewer.
  • Click and drag bounding boxes around objects in the image. Each time you draw a bounding box a segmentation is generated in the region selected.

screenshot

You can choose to auto-increment the label index to distinguish individual objects. Deselect that option to annotate a single foreground class.

Running the segmentation via a web API

You can run the rembg segmentation via a web API running in a docker container.

Advantages

  • The segmentation can be run on a remote machine with optimization (e.g. GPU).
  • The segmentation models will be downloaded inside the docker container instead of the user's file system.
  • You can minimally install the package with pip install napari-rembg on the client's machine. This will not install the rembg library, which can solve potential dependency conflicts or bugs.

Setup

See these instructions on how to set up the docker container and web API.

Usage

Start napari-rembg from the Plugins menu of Napari:

Plugins > Napari Select Foreground > Select foreground (Web API)

If you are looking for similar generalist segmentation plugins, check out these related projects:

Contributing

Contributions are very welcome.

License

Distributed under the terms of the BSD-3 license, "napari-rembg" is free and open source software.

Issues

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


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

Metadata

Release files for napari-rembg 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for napari-rembg 0.0.7
File Size Uploaded Provenance Actions
napari-rembg-0.0.7.tar.gz 11.6 kB Without provenance Details for napari-rembg-0.0.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for napari-rembg 0.0.7
File Interpreter ABI Platform Actions
napari_rembg-0.0.7-py3-none-any.whl Python 3 none any Details for napari_rembg-0.0.7-py3-none-any.whl

Total release size: 23.0 kB

Release files / napari-rembg-0.0.7.tar.gz

Download URL napari-rembg-0.0.7.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2d44d3b5804cdb52d3cd7341d6f2b71f60a8bceb94b535ee046695ca1049bb46
BLAKE2b-256 checksum
How to use checksums
4f3a074f3be864fbf3e5b4fd82b8c566cd73409fb69287aec6190aab8802cb0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Release files / napari_rembg-0.0.7-py3-none-any.whl

Download URL napari_rembg-0.0.7-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ddc555773c78d979914f129fe5be1c23889fbb4fe9d1ce0957e9e94e9deb0b4a
BLAKE2b-256 checksum
How to use checksums
ee7c0506986d85fb0b7ef9612ce0525a34001ae32f6fd12fc2eadd7c041b1675
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Security for napari-rembg 0.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page