Skip to content

Segmentation Module

Train U-Net models for biomedical image segmentation or use pretrained models to segment new data.

Segmentation Module OverviewThe Segmentation module showing the step navigation and workflow selection


Overview

The Segmentation module provides a complete machine learning pipeline for training and applying U-Net segmentation models. It supports two workflows:

WorkflowDescriptionSteps
Train from ScratchTrain a new model using your images and annotationsStep 1 → Step 2 → Step 3 → Step 4
Import Pretrained ModelUse an existing model to segment new dataStep 1 → Step 4 (skip Steps 2-3)

For more background, see Segmentation Overview.


Quick Start

Training Workflow

  1. Launch the Segmentation module from the Hub
  2. Expand "Train from Scratch" and select your raw images and annotations
  3. Configure training parameters (or use defaults)
  4. Start training and monitor progress
  5. Upload inference data and run segmentation

Import Model Workflow

  1. Launch the Segmentation module from the Hub
  2. Expand "Use Pretrained Model" and select your model (.pth) and config (.json) files
  3. Skip to Step 4, upload inference data, and run segmentation

Step-by-Step Guide

Step 1: Training Data or Model Selection

This step offers two mutually exclusive workflows. Expanding one section will collapse the other. For help choosing, see Workflow Choice.

Step 1 Workflow SelectionChoose between training a new model or importing an existing one

Option A: Train from Scratch

Expand the Train from Scratch section to upload your training data:

InputFormatDescription
Raw ImagesTIFF stackYour microscopy images for training. See Raw Images
AnnotationsTIFF stackCorresponding segmentation masks (same dimensions). See Annotations

Both files must have matching dimensions (width, height, number of slices).

To select files:

  1. Click the file selector for each input type
  2. Choose a file from your workspace or upload a new one
  3. Wait for validation to complete (green checkmark indicates success)
  4. Click Next: Configuration when both files are validated

Option B: Use Pretrained Model

Expand the Use Pretrained Model section to import an existing model:

InputFormatDescription
Model File.pthPyTorch model weights. See Model File
Config File.jsonModel configuration (architecture, classes). See Config File

Note: When using a pretrained model, Steps 2 and 3 are skipped. After validation, click Next to proceed directly to Step 4 (Inference).


Step 2: Training Configuration

This step is only shown for the Train from Scratch workflow.

Configure how your model will be trained. Default values work well for most cases.

Step 2 ConfigurationTraining configuration with dataset, architecture, and training parameters

Dataset Configuration

ParameterDefaultOptionsHelp Article
Patch Size6432, 48, 64, 96, 128, 256Patch Size
Patches per Image501–100Patches per Image
Batch Size81, 2, 4, 8, 16, 32Batch Size
Data AugmentationEnabledOn/OffAugmentation

Model Architecture

ParameterDefaultOptionsHelp Article
Number of Features6432, 48, 64, 96, 128Number of Features
Number of Layers42–6Number of Layers

Training Parameters

ParameterDefaultOptionsHelp Article
Learning Rate1e-31e-5 to 2e-3Learning Rate
Number of Epochs10010–500Number of Epochs

Click Next: Training when you're satisfied with your configuration.


Step 3: Training Progress

This step is only shown for the Train from Scratch workflow.

Monitor your model as it learns to segment your images. For details on interpreting training metrics, see Training Progress.

Step 3 TrainingTraining progress with real-time metrics and charts

Starting Training

  1. Review your configuration summary
  2. Click Start Training to begin
  3. The progress display will show:
    • Current epoch / total epochs
    • Progress bar
    • Real-time metrics (Training Loss, Validation Loss, Training Dice, Validation Dice)

Training Charts

ChartDescriptionHelp Article
Loss CurvesShows training and validation loss over epochsLoss Curves
Dice ScoreShows segmentation accuracy over epochsDice Score

Good training shows both curves converging, with validation metrics close to training metrics.

During Training

Tip: You don't need to watch the entire training process. Feel free to explore other modules while training continues in the background. Note that only one training session can run at a time.

  • Cancel Training: Click Cancel Training if you need to stop early
  • Page Refresh: If you accidentally refresh the page, the module will detect an active training session and offer to resume monitoring

Training Completion

When training finishes:

  • The Next: Inference button becomes enabled
  • Your trained model is automatically saved
  • Metrics display shows final values

Click Next: Inference to proceed.


Step 4: Run Inference

Apply your trained (or imported) model to segment new data. See Inference Overview.

Step 4 InferenceUpload data and run segmentation with your model

Select Inference Data

  1. Click the file selector to choose your inference data
  2. Select a TIFF stack from your workspace or upload a new one
  3. The data should be similar to your training images (same modality, resolution)

For data requirements, see Inference Data.

Run Segmentation

  1. Click Run Segmentation after selecting valid data
  2. Monitor the progress bar showing slice-by-slice processing
  3. Wait for the completion message

After Completion

When segmentation finishes, you'll see two options:

ActionDescription
Open in Image ViewerView your segmentation results immediately. See the Image Viewer Guide for navigation controls
Start New AnalysisReset the module to begin a new training or inference workflow

Output Files

The Segmentation module saves files to your workspace:

WorkflowOutput LocationFiles
Trainingmodels/<session>/<training-id>/best_model.pth, config.json, results.json
Inferenceresults/<inference-id>/Segmented TIFF stack, metadata JSON

These files appear in your workspace file browser after processing completes.


Troubleshooting

IssuePossible CauseSolution
Validation fails for training dataDimension mismatch between images and annotationsEnsure both TIFF stacks have identical dimensions
Training loss not decreasingLearning rate too high or data issueTry reducing learning rate; verify annotations are correct
Poor segmentation qualityInsufficient training data or epochsAdd more training data or increase epoch count
"Model file invalid" errorIncompatible model architectureEnsure model and config files are from the same training session
Inference very slowLarge image stackThis is normal; processing is slice-by-slice

Module Overview

Step 1: Data Selection

Step 2: Configuration

Step 3: Training

Step 4: Inference

Part of DFG Priority Programme SPP2332 "Physics of Parasitism"