Cellpose CLI

See example usage at CLI examples. A description of the most important settings can be found on the Settings page.

Command Line Usage

Cellpose Command Line Parameters

usage: cellpose [-h] [--version] [--verbose] [--Zstack] [--use_gpu]
                [--gpu_device GPU_DEVICE] [--check_mkl] [--dir DIR]
                [--image_path IMAGE_PATH] [--look_one_level_down]
                [--img_filter IMG_FILTER] [--channel_axis CHANNEL_AXIS]
                [--z_axis Z_AXIS] [--chan CHAN] [--chan2 CHAN2] [--invert]
                [--all_channels] [--pretrained_model PRETRAINED_MODEL]
                [--restore_type RESTORE_TYPE] [--chan2_restore]
                [--add_model ADD_MODEL] [--transformer]
                [--pretrained_model_ortho PRETRAINED_MODEL_ORTHO]
                [--no_resample] [--no_interp] [--no_norm] [--do_3D]
                [--diameter DIAMETER] [--stitch_threshold STITCH_THRESHOLD]
                [--min_size MIN_SIZE] [--dP_smooth DP_SMOOTH]
                [--flow_threshold FLOW_THRESHOLD]
                [--cellprob_threshold CELLPROB_THRESHOLD] [--niter NITER]
                [--anisotropy ANISOTROPY] [--exclude_on_edges] [--augment]
                [--save_png] [--save_tif] [--no_npy] [--savedir SAVEDIR]
                [--dir_above] [--in_folders] [--save_flows] [--save_outlines]
                [--save_rois] [--save_txt] [--save_mpl] [--train]
                [--train_size] [--test_dir TEST_DIR] [--file_list FILE_LIST]
                [--mask_filter MASK_FILTER] [--diam_mean DIAM_MEAN]
                [--learning_rate LEARNING_RATE] [--weight_decay WEIGHT_DECAY]
                [--n_epochs N_EPOCHS] [--batch_size BATCH_SIZE]
                [--nimg_per_epoch NIMG_PER_EPOCH]
                [--nimg_test_per_epoch NIMG_TEST_PER_EPOCH]
                [--min_train_masks MIN_TRAIN_MASKS] [--SGD SGD]
                [--save_every SAVE_EVERY] [--model_name_out MODEL_NAME_OUT]

Named Arguments

--version

show cellpose version info

Default: False

--verbose

show information about running and settings and save to log

Default: False

--Zstack

run GUI in 3D mode

Default: False

Hardware Arguments

--use_gpu

use gpu if torch with cuda installed

Default: False

--gpu_device

which gpu device to use, use an integer for torch, or mps for M1

Default: '0'

--check_mkl

check if mkl working

Default: False

Input Image Arguments

--dir

folder containing data to run or train on.

Default: []

--image_path

if given and –dir not given, run on single image instead of folder (cannot train with this option)

Default: []

--look_one_level_down

run processing on all subdirectories of current folder

Default: False

--img_filter

end string for images to run on

Default: []

--channel_axis

axis of image which corresponds to image channels

--z_axis

axis of image which corresponds to Z dimension

--chan

channel to segment; 0: GRAY, 1: RED, 2: GREEN, 3: BLUE. Default: 0

Default: 0

--chan2

nuclear channel (if cyto, optional); 0: NONE, 1: RED, 2: GREEN, 3: BLUE. Default: 0

Default: 0

--invert

invert grayscale channel

Default: False

--all_channels

use all channels in image if using own model and images with special channels

Default: False

Model Arguments

--pretrained_model

model to use for running or starting training

Default: 'cyto3'

--restore_type

model to use for image restoration

--chan2_restore

use nuclei restore model for second channel

Default: False

--add_model

model path to copy model to hidden .cellpose folder for using in GUI/CLI

--transformer

use transformer backbone (pretrained_model from Cellpose3 is transformer_cp3)

Default: False

--pretrained_model_ortho

model to use for running 3D ortho views (ZY and ZX)

Algorithm Arguments

--no_resample

disable dynamics on full image (makes algorithm faster for images with large diameters)

Default: False

--no_interp

do not interpolate when running dynamics (was default)

Default: False

--no_norm

do not normalize images (normalize=False)

Default: False

--do_3D

process images as 3D stacks of images (nplanes x nchan x Ly x Lx

Default: False

--diameter

cell diameter, if 0 will use the diameter of the training labels used in the model, or with built-in model will estimate diameter for each image

Default: 30.0

--stitch_threshold

compute masks in 2D then stitch together masks with IoU>0.9 across planes

Default: 0.0

--min_size

minimum number of pixels per mask, can turn off with -1

Default: 15

--dP_smooth

stddev of gaussian for smoothing of dP for dynamics in 3D, default of 0 means no smoothing

Default: 0

--flow_threshold

flow error threshold, 0 turns off this optional QC step. Default: 0.4

Default: 0.4

--cellprob_threshold

cellprob threshold, default is 0, decrease to find more and larger masks

Default: 0

--niter

niter, number of iterations for dynamics for mask creation, default of 0 means it is proportional to diameter, set to a larger number like 2000 for very long ROIs

Default: 0

--anisotropy

anisotropy of volume in 3D

Default: 1.0

--exclude_on_edges

discard masks which touch edges of image

Default: False

--augment

tiles image with overlapping tiles and flips overlapped regions to augment

Default: False

Output Arguments

--save_png

save masks as png and outlines as text file for ImageJ

Default: False

--save_tif

save masks as tif and outlines as text file for ImageJ

Default: False

--no_npy

suppress saving of npy

Default: False

--savedir

folder to which segmentation results will be saved (defaults to input image directory)

--dir_above

save output folders adjacent to image folder instead of inside it (off by default)

Default: False

--in_folders

flag to save output in folders (off by default)

Default: False

--save_flows

whether or not to save RGB images of flows when masks are saved (disabled by default)

Default: False

--save_outlines

whether or not to save RGB outline images when masks are saved (disabled by default)

Default: False

--save_rois

whether or not to save ImageJ compatible ROI archive (disabled by default)

Default: False

--save_txt

flag to enable txt outlines for ImageJ (disabled by default)

Default: False

--save_mpl

save a figure of image/mask/flows using matplotlib (disabled by default). This is slow, especially with large images.

Default: False

Training Arguments

--train

train network using images in dir

Default: False

--train_size

train size network at end of training

Default: False

--test_dir

folder containing test data (optional)

Default: []

--file_list

path to list of files for training and testing and probabilities for each image (optional)

Default: []

--mask_filter

end string for masks to run on. use ‘_seg.npy’ for manual annotations from the GUI. Default: ‘_masks’

Default: '_masks'

--diam_mean

mean diameter to resize cells to during training – if starting from pretrained models it cannot be changed from 30.0

Default: 30.0

--learning_rate

learning rate. Default: 0.2

Default: 0.2

--weight_decay

weight decay. Default: 1e-05

Default: 1e-05

--n_epochs

number of epochs. Default: 500

Default: 500

--batch_size

batch size. Default: 8

Default: 8

--nimg_per_epoch

number of train images per epoch. Default is to use all train images.

--nimg_test_per_epoch

number of test images per epoch. Default is to use all test images.

--min_train_masks

minimum number of masks a training image must have to be used. Default: 5

Default: 5

--SGD

use SGD

Default: 1

--save_every

number of epochs to skip between saves. Default: 100

Default: 100

--model_name_out

Name of model to save as, defaults to name describing model architecture. Model is saved in the folder specified by –dir in models subfolder.