@@ -1315,15 +1315,46 @@ def micro_sam_info():
13151315 )
13161316 )
13171317
1318+ # Creating a cache directory when users' run `micro_sam.info`.
1319+ cache_dir = get_cache_directory ()
1320+ os .makedirs (cache_dir , exist_ok = True )
1321+
13181322 # The cache directory panel.
13191323 console .print (
1320- Panel (f"[bold #009E73]Cache Directory:[/bold #009E73]\n { get_cache_directory () } " , title = "Cache Directory" )
1324+ Panel (f"[bold #009E73]Cache Directory:[/bold #009E73]\n { cache_dir } " , title = "Cache Directory" )
13211325 )
13221326
13231327 # The available models panel.
1324- available_models = list (get_model_names ())
1328+ curr_models = list (get_model_names ())
13251329 # We filter out the decoder models.
1326- available_models = [m for m in available_models if not m .endswith ("_decoder" )]
1330+ curr_models = [m for m in curr_models if not m .endswith ("_decoder" )]
1331+
1332+ # We have a simple versioning logic here (which is what I'll follow here for mapping model versions).
1333+ available_models = []
1334+ for model_name , model_path in models ().urls .items (): # We filter out the decoder models.
1335+ if model_name .endswith ("decoder" ):
1336+ continue
1337+
1338+ if "https://dl.fbaipublicfiles.com/segment_anything/" in model_path : # Valid v1 SAM models.
1339+ available_models .append (model_name )
1340+
1341+ if "https://owncloud.gwdg.de/" in model_path : # Our own hosted models (in their v1 mode quite often)
1342+ if model_name == "vit_t" : # MobileSAM model.
1343+ available_models .append (model_name )
1344+ else :
1345+ available_models .append (f"{ model_name } (v1)" )
1346+
1347+ # Now for our models, the BioImageIO ModelZoo upload structure is such that:
1348+ # '/1/files' corresponds to v2 models.
1349+ # '/1.1/files' corresponds to v3 models.
1350+ # '/1.2/files' corresponds to v4 models.
1351+ if "/1/files" in model_path :
1352+ available_models .append (f"{ model_name } (v2)" )
1353+ if "/1.1/files" in model_path :
1354+ available_models .append (f"{ model_name } (v3)" )
1355+ if "/1.2/files" in model_path :
1356+ available_models .append (f"{ model_name } (v4)" )
1357+
13271358 model_list = "\n " .join (available_models )
13281359 console .print (
13291360 Panel (f"[bold #D55E00]Available Models:[/bold #D55E00]\n { model_list } " , title = "List of Supported Models" )
0 commit comments