From 36aa2cfcf12e64e4bde5a286a9359b467b809ec5 Mon Sep 17 00:00:00 2001 From: qiqiWav Date: Thu, 14 Nov 2024 00:19:47 +0000 Subject: [PATCH] remove projector --- dependency/bark.cpp | 2 +- dependency/llama.cpp | 2 +- nexa/general.py | 23 ++++++++++++++++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/dependency/bark.cpp b/dependency/bark.cpp index f4ab4420..1c228860 160000 --- a/dependency/bark.cpp +++ b/dependency/bark.cpp @@ -1 +1 @@ -Subproject commit f4ab4420973d04055225c85be2ca7c0273e65074 +Subproject commit 1c22886058af2ff72b92624bc86f88cc11a3dfc6 diff --git a/dependency/llama.cpp b/dependency/llama.cpp index bb33473f..b535cd94 160000 --- a/dependency/llama.cpp +++ b/dependency/llama.cpp @@ -1 +1 @@ -Subproject commit bb33473f08db604e1f30334366032f0904e2a722 +Subproject commit b535cd941e657ac1984d8022dd5f0c98f2b9e265 diff --git a/nexa/general.py b/nexa/general.py index 99a6be70..7fca9e6f 100644 --- a/nexa/general.py +++ b/nexa/general.py @@ -127,7 +127,7 @@ def pull_model(model_path, hf = False, **kwargs): if result["success"]: # Only add to model list if not using custom download path model_path = model_path if not hf else f"{model_path}:{result['local_path'].split('/')[-1]}" - if not kwargs.get('local_download_path'): + if not kwargs.get('local_download_path') and 'projector' not in model_path.lower(): add_model_to_list(model_path, result["local_path"], result["model_type"], result["run_type"]) if hf: @@ -559,9 +559,15 @@ def list_models(): with open(NEXA_MODEL_LIST_PATH, "r") as f: model_list = json.load(f) + filtered_list = { + model_name: model_info + for model_name, model_info in model_list.items() + if not model_name.split(':')[1].startswith('projector') + } + table = [ (model_name, model_info["type"], model_info["run_type"], model_info["location"]) - for model_name, model_info in model_list.items() + for model_name, model_info in filtered_list.items() ] headers = ["Model Name", "Type", "Run Type", "Location"] from tabulate import tabulate @@ -578,7 +584,6 @@ def list_models(): except Exception as e: print(f"An error occurred while listing the models: {e}") - def remove_model(model_path): model_path = NEXA_RUN_MODEL_MAP.get(model_path, model_path) @@ -608,6 +613,18 @@ def remove_model(model_path): else: print(f"Warning: Model location not found: {model_path}") + # Delete projectors + projector_keys = [k for k in model_list.keys() if 'projector' in k] + for key in projector_keys: + projector_info = model_list.pop(key) + projector_location = Path(projector_info['location']) + if projector_location.exists(): + if projector_location.is_file(): + projector_location.unlink() + else: + shutil.rmtree(projector_location) + print(f"Deleted projector: {projector_location}") + # Update the model list file with open(NEXA_MODEL_LIST_PATH, "w") as f: json.dump(model_list, f, indent=2)