wolny/pytorch-3dunet

3D U-Net model for volumetric semantic segmentation written in pytorch

What it solves

Volumetric image analysis often requires segmenting structures like cells or nuclei in 3D. pytorch-3dunet provides a ready-to-use implementation of the 3D U-Net architecture and its variants, so researchers can train models to automatically label every voxel in a volume, or to perform regression tasks such as denoising. It handles the heavy lifting of data loading, loss computation, and evaluation.

How it works

The library is built around YAML configuration files that specify the model, data paths, loss function, and training settings. Training is started with train3dunet --config <CONFIG> and prediction with predict3dunet --config <CONFIG>. Input data must be stored in HDF5 files containing raw and label datasets. The code supports both 3D and 2D U-Nets; for 2D, the data keeps a singleton z-dimension. It includes several U-Net variants: standard, residual, and residual with Squeeze-and-Excitation blocks. It also provides many loss functions (e.g., Dice, cross-entropy, mean squared error) and evaluation metrics (e.g., IoU, Dice, PSNR) suitable for segmentation and regression. When multiple GPUs are available, training and prediction automatically use DataParallel.

Who it’s for

Researchers and engineers working with volumetric biological or medical images who need to segment structures (e.g., cell boundaries, nuclei) or perform regression tasks. It is also useful for anyone who wants to apply a proven 3D U-Net implementation without building from scratch.

Highlights

  • Implements 3D U-Net, Residual U-Net, and Residual U-Net with Squeeze-and-Excitation blocks.
  • Supports both semantic segmentation (binary and multi-class) and regression (e.g., denoising).
  • Also supports 2D U-Net by keeping a singleton z-dimension in HDF5.
  • Provides a wide range of loss functions and evaluation metrics for both segmentation and regression.
  • Offers pre-trained models and example configs for plant cell boundary and nuclei segmentation.
  • Can run on multiple GPUs automatically via DataParallel.

Related

  • Project
  • Project
  • Project
  • Project