Skip to main content

a napari plugin for TIFF-based 2D and 3D U-Net segmentation workflows.

Project description

napari-unet-assistant

napari-unet-assistant is a napari plugin for TIFF-based 2D and 3D U-Net segmentation workflows.

It is designed for users who already have paired images and masks and want to train a U-Net model, run inference, and inspect results directly inside napari.

This plugin is different from a SAM-based training assistant. It focuses on conventional supervised U-Net training from existing image-mask pairs.

Current features

  • TIFF-first image and mask pairing
  • 2D U-Net training
  • 3D U-Net training
  • Binary segmentation
  • Multiclass segmentation
  • Patch-based training
  • Optional empty-mask patch inclusion
  • Conservative augmentation
  • 80/20 validation split
  • Continue training from a previous run
  • Inference from a saved run folder
  • Single-image inference
  • Folder inference
  • 2D and 3D prediction support
  • TIFF prediction output
  • napari-based visualization and QC

Installation

pip install git+https://github.com/wulinteousa2-hash/napari-unet-assistant.git

OR

git clone https://github.com/wulinteousa2-hash/napari-unet-assistant.git
cd napari-unet-assistant
pip install -e .
napari

Intended workflow

  1. Prepare an image folder.
  2. Prepare a mask folder.
  3. Pair images and masks by filename.
  4. Train a 2D or 3D U-Net model.
  5. Save the best model checkpoint and training metadata.
  6. Load a saved run folder.
  7. Run inference on new images or volumes.
  8. Review prediction masks in napari.

Supported data

2D training

  • image: (Y, X) grayscale
  • mask: (Y, X) grayscale labels
  • 0 = background , nonzero = foreground

3D training

  • image: (Z, Y, X) grayscale

  • mask: (Z, Y, X) integer labels

  • Multiclass masks should use integer labels, for example:

  • 0 = background

  • 1 = class 1

  • 2 = class 2

  • 3 = class 3

Dtypes observed

  • images: uint8, uint16
  • masks: uint8

Current priorities

  • TIFF first
  • OME-Zarr later
  • no spectral/lambda workflow in this phase

Pairing logic

  • image folder and mask folder are selected separately
  • mask suffixes supported:
    • _mask.tif
    • _mask.tiff
    • _m.tif
    • _m.tiff
  • unmatched items are skipped and reported

Training modes

  • 2D binary default
  • 3D supports:
    • binary
    • multiclass

Patch extraction

2D XY patch options

  • 64
  • 128
  • 256
  • 512
  • 1024

Default:

  • 256 x 256

3D patch options

Z:

  • 8
  • 16
  • 32
  • 64

XY:

  • 64
  • 128
  • 256
  • 512
  • 1024

Default:

  • 16 x 256 x 256

Overlap

  • overlap is percent
  • 0 = no overlap
  • 10 = 10% overlap

Empty-mask patch policy

  • user can choose whether to include empty-mask patches

Backend

  • PyTorch only
  • CPU fallback required
  • CUDA expected
  • DGX Spark target

Validation

  • default: 80/20 split
  • optional: k-fold

Checkpoint policy

  • save best model only

Inference

  • load from saved run folder
  • read JSON config from training
  • TIFF output only

Outputs saved in user-selected run folder

  • best model checkpoint
  • config JSON
  • metrics CSV
  • training history CSV
  • pair report CSV
  • prediction TIFF outputs

Reference

This project builds on U-Net-based nerve morphometry workflows described in:

Moiseev D, Hu B, Li J. Morphometric Analysis of Peripheral Myelinated Nerve Fibers through Deep Learning. Journal of the Peripheral Nervous System. 2019;24(1):87-93. https://pmc.ncbi.nlm.nih.gov/articles/PMC6420354/

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_unet_assistant-0.1.0.tar.gz (31.8 kB view details)

Uploaded Source

Built Distribution

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

napari_unet_assistant-0.1.0-py3-none-any.whl (35.9 kB view details)

Uploaded Python 3

File details

Details for the file napari_unet_assistant-0.1.0.tar.gz.

File metadata

  • Download URL: napari_unet_assistant-0.1.0.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for napari_unet_assistant-0.1.0.tar.gz
Algorithm Hash digest
SHA256 52e324d1f719c86a89639b3ce90d86ff2c3cfdfe6ff488af4403774ac60708ad
MD5 acee3bd4c1d49881b15c4bf61d691dad
BLAKE2b-256 7946bcfa0ef560da16698b4b350dd057e5af9e9de05c2d941b0a5122fff0cb5d

See more details on using hashes here.

File details

Details for the file napari_unet_assistant-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for napari_unet_assistant-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d8b5e9122b140f488b3ab2976de5b1a7529806dbf1ea78089af6ababc945325d
MD5 8afb965bd861292435b9ebd13f7893af
BLAKE2b-256 140bc21a1b6a1e4f0d12e6ac961d3f8d45b372d2e0d6ebffd86c046ba749e35a

See more details on using hashes here.

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