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] [--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]
[--add_model ADD_MODEL]
[--pretrained_model_ortho PRETRAINED_MODEL_ORTHO]
[--restore_type RESTORE_TYPE] [--chan2_restore]
[--transformer] [--no_norm] [--norm_percentile VALUE1 VALUE2]
[--do_3D] [--diameter DIAMETER]
[--stitch_threshold STITCH_THRESHOLD] [--min_size MIN_SIZE]
[--flow3D_smooth FLOW3D_SMOOTH [FLOW3D_SMOOTH ...]]
[--flow_threshold FLOW_THRESHOLD]
[--cellprob_threshold CELLPROB_THRESHOLD] [--niter NITER]
[--anisotropy ANISOTROPY] [--exclude_on_edges] [--augment]
[--batch_size BATCH_SIZE] [--no_resample] [--no_interp]
[--save_png] [--save_tif] [--output_name OUTPUT_NAME]
[--no_npy] [--savedir SAVEDIR] [--dir_above] [--in_folders]
[--save_flows] [--save_outlines] [--save_rois] [--save_txt]
[--save_mpl] [--train] [--test_dir TEST_DIR]
[--file_list FILE_LIST] [--mask_filter MASK_FILTER]
[--learning_rate LEARNING_RATE] [--weight_decay WEIGHT_DECAY]
[--n_epochs N_EPOCHS] [--train_batch_size TRAIN_BATCH_SIZE]
[--bsize BSIZE] [--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] [--save_each]
[--model_name_out MODEL_NAME_OUT] [--diam_mean DIAM_MEAN]
[--train_size]
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 or mps if torch with cuda installed
Default:
False- --gpu_device
which gpu device to use in pytorch, specified as an integer
Default:
'0'
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
Deprecated in v4.0.1+, not used.
Default:
0- --chan2
Deprecated in v4.0.1+, not used.
Default:
0- --invert
Deprecated in v4.0.1+, not used.
Default:
False- --all_channels
Deprecated in v4.0.1+, not used.
Default:
False
Model Arguments
- --pretrained_model
path to model for segmentation or starting training, or builtin model name: cpsam_v2, cpdino, cpdino-vitb, or cpsam
Default:
'cpsam_v2'- --add_model
model path to copy model to hidden .cellpose folder for using in GUI/CLI
- --pretrained_model_ortho
Deprecated in v4.0.1+, not used.
- --restore_type
Deprecated in v4.0.1+, not used.
- --chan2_restore
Deprecated in v4.0.1+, not used.
Default:
False- --transformer
use transformer backbone (pretrained_model from Cellpose3 is transformer_cp3)
Default:
False
Algorithm Arguments
- --no_norm
do not normalize images (normalize=False)
Default:
False- --norm_percentile
Provide two float values to set norm_percentile (e.g., –norm_percentile 1 99)
- --do_3D
process images as 3D stacks of images (nplanes x nchan x Ly x Lx
Default:
False- --diameter
use to resize cells to the training diameter (30 pixels)
- --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- --flow3D_smooth
stddev of gaussian for smoothing of dP for dynamics in 3D, default of 0 means no smoothing. If you are seeing increased fragmentation along the Z axis, or ring-artifacts, you can specify increased smoothing in the z-axis by providing a list, e.g. –flow3D_smooth 2 1 1. Pass a list of values to allow smoothing of the ZYX axes independently
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- --batch_size
inference batch size. Default: 8
Default:
8- --no_resample
disables flows/cellprob resampling to original image size before computing masks. Using this flag will make more masks more jagged with larger diameter settings.
Default:
False- --no_interp
do not interpolate when running dynamics (was default)
Default:
False
Output Arguments
- --save_png
save masks as png
Default:
False- --save_tif
save masks as tif
Default:
False- --output_name
suffix for saved masks, default is _cp_masks, can be empty if savedir used and different of dir
- --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- --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'- --learning_rate
learning rate. Default: 1e-05
Default:
1e-05- --weight_decay
weight decay. Default: 0.1
Default:
0.1- --n_epochs
number of epochs. Default: 100
Default:
100- --train_batch_size
training batch size. Default: 1
Default:
1- --bsize
block size for tiles. Default: 256
Default:
256- --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
Deprecated in v4.0.1+, not used - AdamW used instead.
Default:
0- --save_every
number of epochs to skip between saves. Default: 100
Default:
100- --save_each
wether or not to save each epoch. Must also use –save_every. (default: False)
Default:
False- --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.
- --diam_mean
Deprecated in v4.0.1+, not used.
Default:
30.0- --train_size
Deprecated in v4.0.1+, not used.
Default:
False