Skip to main content

AI-based foreground extraction in scientific and natural images.

Project description

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)

Related projects

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.

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-rembg-0.0.7.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

napari_rembg-0.0.7-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file napari-rembg-0.0.7.tar.gz.

File metadata

  • Download URL: napari-rembg-0.0.7.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for napari-rembg-0.0.7.tar.gz
Algorithm Hash digest
SHA256 2d44d3b5804cdb52d3cd7341d6f2b71f60a8bceb94b535ee046695ca1049bb46
MD5 23a57d652ab5ec2d3f02b9d07a7b576a
BLAKE2b-256 4f3a074f3be864fbf3e5b4fd82b8c566cd73409fb69287aec6190aab8802cb0f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: napari_rembg-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for napari_rembg-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ddc555773c78d979914f129fe5be1c23889fbb4fe9d1ce0957e9e94e9deb0b4a
MD5 805f144d73e4a8611ce129dfe11370bd
BLAKE2b-256 ee7c0506986d85fb0b7ef9612ce0525a34001ae32f6fd12fc2eadd7c041b1675

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page