@@ -87,12 +87,51 @@ def _next_image(v):
8787 napari .run ()
8888
8989
90- def image_folder_annotator (root_folder , output_folder , pattern = "*" , embedding_path = None , ** kwargs ):
91- image_files = sorted (glob (os .path .join (root_folder , pattern )))
90+ def image_folder_annotator (input_folder , output_folder , pattern = "*" , embedding_path = None , ** kwargs ):
91+ image_files = sorted (glob (os .path .join (input_folder , pattern )))
9292 image_series_annotator (image_files , output_folder , embedding_path , ** kwargs )
9393
9494
95- # TODO implement the CLI
9695def main ():
9796 import argparse
98- image_folder_annotator ()
97+
98+ parser = argparse .ArgumentParser (description = "Annotate a series of images from a folder." )
99+ parser .add_argument (
100+ "-i" , "--input_folder" , required = True ,
101+ help = "The folder containing the image data. The data can be stored in any common format (tif, jpg, png, ...)."
102+ )
103+ parser .add_argument (
104+ "-o" , "--output_folder" , required = True ,
105+ help = "The folder where the segmentation results will be stored."
106+ )
107+ parser .add_argument (
108+ "-p" , "--pattern" , default = "*" ,
109+ help = "The pattern to select the images to annotator from the input folder. E.g. *.tif to annotate all tifs."
110+ "By default all files in the folder will be loaded and annotated."
111+ )
112+ parser .add_argument (
113+ "-e" , "--embedding_path" ,
114+ help = "The filepath for saving/loading the pre-computed image embeddings. "
115+ "NOTE: It is recommended to pass this argument and store the embeddings, "
116+ "otherwise they will be recomputed every time (which can take a long time)."
117+ )
118+ parser .add_argument (
119+ "--model_type" , default = "vit_h" , help = "The segment anything model that will be used, one of vit_h,l,b."
120+ )
121+ parser .add_argument (
122+ "--tile_shape" , nargs = "+" , type = int , help = "The tile shape for using tiled prediction" , default = None
123+ )
124+ parser .add_argument (
125+ "--halo" , nargs = "+" , type = int , help = "The halo for using tiled prediction" , default = None
126+ )
127+
128+ args = parser .parse_args ()
129+
130+ if args .embedding_path is None :
131+ warnings .warn ("You have not passed an embedding_path. Restarting the annotator may take a long time." )
132+
133+ image_folder_annotator (
134+ args .input_folder , args .output_folder , args .pattern ,
135+ embedding_path = args .embedding_path , model_type = args .model_type ,
136+ tile_shape = args .tile_shape , halo = args .halo ,
137+ )
0 commit comments