From d8258c8e2a9ddd4a39e569a223db18c154f41fae Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Wed, 3 Apr 2024 20:37:44 +1100 Subject: [PATCH] feat(mm): hide missing models from API response Check if the model file exists. If not, omit it from the list of models. Closes #6117 --- invokeai/app/api/routers/model_manager.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/invokeai/app/api/routers/model_manager.py b/invokeai/app/api/routers/model_manager.py index 015afa4678..90fe428d1c 100644 --- a/invokeai/app/api/routers/model_manager.py +++ b/invokeai/app/api/routers/model_manager.py @@ -117,10 +117,14 @@ async def list_model_records( found_models.extend( record_store.search_by_attr(model_type=model_type, model_name=model_name, model_format=model_format) ) - for model in found_models: + + models_path = ApiDependencies.invoker.services.configuration.models_path + existant_models = [m for m in found_models if (models_path / m.path).exists()] + + for model in existant_models: cover_image = ApiDependencies.invoker.services.model_images.get_url(model.key) model.cover_image = cover_image - return ModelsList(models=found_models) + return ModelsList(models=existant_models) @model_manager_router.get(