A napari plugin for Segment Anything Model 3 (SAM3) image segmentation with Simple and Advanced workflows, text, points, boxes, exemplars, large-image ROI inference, mask operations, and 3D/video-like propagation
Project description
napari-sam3-assistant
napari-sam3-assistant is a napari plugin for local Segment Anything Model 3
(SAM3) segmentation. It provides:
- a guided
Simplemode for common segmentation work; - an
Advancedmode for model setup, batch runs, local ROI inference, result tables, and 3D/video-style propagation; - a separate
SAM3 Mask Operationswidget for cleanup, relabeling, isolation, merge, overlap inspection, and export.
The plugin is intended for researchers who want SAM3 results back in napari as
normal Labels, Shapes, and table-style outputs that can be reviewed,
corrected, saved, and exported.
What It Does
- Segment 2D images with point, box/Shapes, labels-mask, text, or exemplar prompts.
- Search for similar features with exemplar prompting from a drawn region or crop image.
- Correct previews with Live Points using positive and negative clicks.
- Run local ROI inference on large TIFF or OME-Zarr-style images.
- Scan large 2D images tile by tile from an exemplar ROI and stitch the result into full-size labels.
- Propagate prompts through 3D stacks or video-like data when the installed SAM3 backend supports the workflow.
- Save previews, clean connected components, relabel values, isolate overlapping candidates, merge labels/layers, inspect overlap, and export final masks.
Documentation
Start here:
Specialized setup:
Maintainer notes:
Quick Start
- Install napari, PyTorch, the SAM3 backend, and this plugin.
- Download the SAM3 model files from Meta's gated Hugging Face repositories.
- Launch napari.
- Open
Plugins > SAM3 Assistant. - Choose a model folder.
- In
Simplemode, select an image, choose a task tab, add a prompt, and clickRun,Run Current ROI, orStart 3D. - Use
Mask OpsorPlugins > SAM3 Mask Operationswhen the preview needs cleanup, merge, or export.
For full setup commands, see Installation.
Requirements
- Python
>=3.11 - napari
>=0.5 - SAM3 Python package importable as
sam3 - CUDA-enabled PyTorch and torchvision for normal use
- Local SAM3 model directory containing:
config.jsonprocessor_config.json- a weight file such as
sam3.pt,model.safetensors, orsam3.1_multiplex.pt
CPU-only use is experimental and limited to SAM3.0 2D image workflows with a CPU-safe SAM3 backend. See CPU-only SAM3.0 setup.
Model Files
SAM3 is not bundled with this plugin. Install the SAM3 backend separately and download model files from Meta's gated Hugging Face repositories:
Example SAM3.0 folder:
D:\models\sam3\
config.json
processor_config.json
sam3.pt
Example SAM3.1 folder:
D:\models\sam3_1\
config.json
processor_config.json
sam3.1_multiplex.pt
Current model support:
- SAM3.0 weights: 2D image tasks and 3D/video propagation
- SAM3.1
sam3.1_multiplex.pt: 3D/video propagation through the SAM3.1 multiplex video predictor - SAM3.1 is not currently routed through the plugin's 2D image model loader
See Model setup for validation and device details.
Prompt Guidance
For microscopy and other research images, the most useful prompts are usually visual examples and local corrections, not text descriptions.
Recommended starting order:
Exemplarwith a box or Shapes region for feature search.Live Pointswith positive and negative points for local correction and repeatable object-by-object segmentation.3D Multiplexwith a box or Shapes region for propagating one selected object through slices or frames.2D Slicewith point or box prompts for quick single-plane local masks.
Text prompting is available, but it is least reliable for specialized microscopy/anatomy terms. Labels-mask prompts are also available, but they are best treated as an advanced option when you already have a useful rough mask.
Shapes prompts are treated as bounding boxes by the current SAM3 prompt path. Rectangles are the clearest choice. Polygons can mark a region, but SAM3 receives the polygon's bounding rectangle, not the exact polygon contour.
See User guide for detailed examples.
Workflow Highlights
Fast local segmentation loop:
- Use
Exemplar,2D Slice, or a box/Shapes prompt to create a preview. - Switch to
Live Pointswhen the preview is close. - Add positive points on missed parts and negative points on leakage.
- Use the Live Points right-click menu to
Accept + Clear. - Click
Save LabelsorSave & Clean. - Move to the next object or ROI and repeat.
Exemplar scan loop:
- Draw a tight exemplar region around a representative object.
- Run the current ROI first.
- If the ROI result is good, scan the full image by tiles.
- Use
SAM3 Mask Operationsfor cleanup, isolation, merge, and export.
Advanced mode also includes Detection threshold, with default 0.35. Lower
values accept weaker candidates and may add false positives. Higher values are
stricter and may miss faint or uncommon structures. The Results table Score
is backend confidence when available; it is a review aid, not a scientific
quality measurement.
Output Layers
Common preview layers:
SAM3 preview labels
SAM3 preview masks
SAM3 preview boxes
SAM3 propagated preview labels
SAM3 tiled exemplar labels
SAM3 tiled exemplar masks
SAM3 tiled exemplar boxes
Common saved or curated layers:
SAM3 saved labels
SAM3 saved propagated labels
SAM3 saved tiled exemplar labels
isolated_objects
merged_class_mask
final_training_mask
Current Status
This project is young and under active development. The core inference workflow is stable: collect prompts in napari, run SAM3 locally, write previews back to napari, and help users save masks. Mask Operations is useful but still evolving. The UI may continue to change, so the documentation is organized around user tasks rather than exact layout alone.
Development
Install in editable mode:
pip install -e .
Run tests:
PYTHONPATH=src pytest -q
The test suite covers coordinate mapping, prompt collection, adapter utility behavior, mask operation services, and static widget UI checks. It does not download SAM3 weights.
References
- SAM3 repository: https://github.com/facebookresearch/sam3
- SAM3 model files: https://huggingface.co/facebook/sam3
- PyTorch installation selector: https://pytorch.org/get-started/locally/
Acknowledgement
The demo image was provided by the Electron Microscopy Core Facility at Houston Methodist Research Institute.
License
MIT. See the project license file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file napari_sam3_assistant-4.3.4.tar.gz.
File metadata
- Download URL: napari_sam3_assistant-4.3.4.tar.gz
- Upload date:
- Size: 160.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07dcd364d4f38c395d2909194e16f06a065bc03a3341248810b86e3b8e156698
|
|
| MD5 |
ea34ff4118355923b430a85d5bcffda9
|
|
| BLAKE2b-256 |
4980b836a42fd5794063ee385345f5f36f0e509e280d0cbe82bdb81f3dfa364d
|
File details
Details for the file napari_sam3_assistant-4.3.4-py3-none-any.whl.
File metadata
- Download URL: napari_sam3_assistant-4.3.4-py3-none-any.whl
- Upload date:
- Size: 170.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f90c75b974c917ed7f2e1b0c5c0f8d07b817469022b6cac8d25f6f3ce3cc9a14
|
|
| MD5 |
9d3ddd58e19b612e98c700339a8230de
|
|
| BLAKE2b-256 |
a291256db8cca7e5ed7cb6e7294129a2b77f536e2adf1fba487d04cf6fd291f0
|