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] [--no_resample]
                [--no_interp] [--no_norm] [--do_3D] [--diameter DIAMETER]
                [--stitch_threshold STITCH_THRESHOLD] [--min_size MIN_SIZE]
                [--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


show cellpose version info

Default: False


show information about running and settings and save to log

Default: False


run GUI in 3D mode

Default: False

Hardware Arguments


use gpu if torch with cuda installed

Default: False


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

Default: “0”


check if mkl working

Default: False

Input Image Arguments


folder containing data to run or train on.

Default: []


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

Default: []


run processing on all subdirectories of current folder

Default: False


end string for images to run on

Default: []


axis of image which corresponds to image channels


axis of image which corresponds to Z dimension


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

Default: 0


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

Default: 0


invert grayscale channel

Default: False


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

Default: False

Model Arguments


model to use for running or starting training

Default: “cyto”


model to use for image restoration


use nuclei restore model for second channel

Default: False


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


use transformer backbone (pretrained_model from Cellpose3 is transformer_cp3)

Default: False

Algorithm Arguments


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

Default: False


do not interpolate when running dynamics (was default)

Default: False


do not normalize images (normalize=False)

Default: False


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

Default: False


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


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

Default: 0.0


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

Default: 15


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

Default: 0.4


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

Default: 0


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 of volume in 3D

Default: 1.0


discard masks which touch edges of image

Default: False


tiles image with overlapping tiles and flips overlapped regions to augment

Default: False

Output Arguments


save masks as png and outlines as text file for ImageJ

Default: False


save masks as tif and outlines as text file for ImageJ

Default: False


suppress saving of npy

Default: False


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


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

Default: False


flag to save output in folders (off by default)

Default: False


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

Default: False


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

Default: False


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

Default: False


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

Default: False


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

Default: False

Training Arguments


train network using images in dir

Default: False


train size network at end of training

Default: False


folder containing test data (optional)

Default: []


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

Default: []


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

Default: “_masks”


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. Default: 0.2

Default: 0.2


weight decay. Default: 1e-05

Default: 1e-05


number of epochs. Default: 500

Default: 500


batch size. Default: 8

Default: 8


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


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


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

Default: 5


use SGD

Default: 1


number of epochs to skip between saves. Default: 100

Default: 100


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