Skip to content

copick inference nnunet

torch

Run nnUNet inference on CoPick tomograms.

Plugin command — copick-torch

This command is provided by the copick-torch plugin, not copick core. Install it to make this command available:

pip install copick-torch

See the plugin system guide for details.

Usage

copick inference nnunet [OPTIONS]

Description

For every run in the project, queries the requested tomogram, runs sliding-window nnUNet prediction, and writes the resulting segmentation back into the CoPick project. All available GPUs are used automatically, with run IDs sharded across devices for batch inference.

Repeat -w/--weights to ensemble multiple folds (logits are averaged before argmax). Both standard nnUNet and MedNeXt trainers are supported; the trainer class is resolved from the checkpoint metadata.

Options

Option Type Default Description
-c, --config path required Path to copick config.json
-p, --plans path required Path to nnunet plans.json
-d, --dataset path required Path to nnunet dataset.json
-w, --weights path · multiple required Path to checkpoint .pth (repeat for fold ensembling, e.g. -w fold_0/checkpoint_best.pth -w fold_1/checkpoint_best.pth)
-turi, --tomo-uri text wbp@10.0 Tomogram URI to predict
--tta boolean True Enable mirroring TTA.
--run-ids, -runs text CoPick run IDs to predict (comma-separated).
-suri, --seg-uri text predict:nnunet/1 Segmentation URI to write (name:user_id/session_id)

Examples

# Segment all runs with a single-fold model, writing to predict:nnunet/1
copick inference nnunet -c config.json -p plans.json -d dataset.json \
    -w fold_0/checkpoint_best.pth -turi wbp@10.0

# Ensemble multiple folds and write to a custom segmentation URI
copick inference nnunet -c config.json -p plans.json -d dataset.json \
    -w fold_0/checkpoint_best.pth -w fold_1/checkpoint_best.pth \
    -suri membrane:nnunet/1

# Predict only specific runs with mirroring TTA disabled
copick inference nnunet -c config.json -p plans.json -d dataset.json \
    -w fold_0/checkpoint_best.pth -runs TS_01,TS_02 --tta False

See also