add --list-models command

This commit is contained in:
Lincoln Stein 2023-07-14 19:52:47 -04:00
parent eb9d74653d
commit a45f7ce355
4 changed files with 14 additions and 6 deletions

View File

@ -836,9 +836,9 @@ def main():
download_support_models() download_support_models()
if opt.skip_sd_weights: if opt.skip_sd_weights:
logger.info("\n** SKIPPING DIFFUSION WEIGHTS DOWNLOAD PER USER REQUEST **") logger.warning("SKIPPING DIFFUSION WEIGHTS DOWNLOAD PER USER REQUEST")
elif models_to_download: elif models_to_download:
logger.info("\n** DOWNLOADING DIFFUSION WEIGHTS **") logger.info("DOWNLOADING DIFFUSION WEIGHTS")
process_and_execute(opt, models_to_download) process_and_execute(opt, models_to_download)
postscript(errors=errors) postscript(errors=errors)

View File

@ -119,6 +119,7 @@ class ModelInstall(object):
# supplement with entries in models.yaml # supplement with entries in models.yaml
installed_models = self.mgr.list_models() installed_models = self.mgr.list_models()
for md in installed_models: for md in installed_models:
base = md['base_model'] base = md['base_model']
model_type = md['model_type'] model_type = md['model_type']
@ -136,6 +137,12 @@ class ModelInstall(object):
) )
return {x : model_dict[x] for x in sorted(model_dict.keys(),key=lambda y: model_dict[y].name.lower())} return {x : model_dict[x] for x in sorted(model_dict.keys(),key=lambda y: model_dict[y].name.lower())}
def list_models(self, model_type):
installed = self.mgr.list_models(model_type=model_type)
print(f'Installed models of type `{model_type}`:')
for i in installed:
print(f"{i['model_name']}\t{i['base_model']}\t{i['path']}")
def starter_models(self)->Set[str]: def starter_models(self)->Set[str]:
models = set() models = set()
for key, value in self.datasets.items(): for key, value in self.datasets.items():

View File

@ -849,7 +849,6 @@ class ModelManager(object):
if autodir is None: if autodir is None:
continue continue
self.logger.info(f'Scanning {autodir} for models to import')
installed = dict() installed = dict()
autodir = self.app_config.root_path / autodir autodir = self.app_config.root_path / autodir
@ -884,9 +883,9 @@ class ModelManager(object):
except ValueError as e: except ValueError as e:
self.logger.warning(str(e)) self.logger.warning(str(e))
self.logger.info(f'Scanned {items_scanned} files and directories, imported {len(new_models_found)} models')
installed.update(new_models_found) installed.update(new_models_found)
self.logger.info(f'Scanned {items_scanned} files and directories, imported {len(new_models_found)} models')
return installed return installed
def heuristic_import(self, def heuristic_import(self,

View File

@ -675,7 +675,9 @@ def select_and_download_models(opt: Namespace):
# pass # pass
installer = ModelInstall(config, prediction_type_helper=helper) installer = ModelInstall(config, prediction_type_helper=helper)
if opt.add or opt.delete: if opt.list_models:
installer.list_models(opt.list_models)
elif opt.add or opt.delete:
selections = InstallSelections( selections = InstallSelections(
install_models = opt.add or [], install_models = opt.add or [],
remove_models = opt.delete or [] remove_models = opt.delete or []
@ -748,7 +750,7 @@ def main():
) )
parser.add_argument( parser.add_argument(
"--list-models", "--list-models",
choices=["diffusers","loras","controlnets","tis"], choices=[x.value for x in ModelType],
help="list installed models", help="list installed models",
) )
parser.add_argument( parser.add_argument(