Skip to content

Commit

Permalink
remove projector
Browse files Browse the repository at this point in the history
  • Loading branch information
qiqiWav committed Nov 14, 2024
1 parent 87e52ed commit 36aa2cf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dependency/bark.cpp
Submodule bark.cpp updated 1 files
+18 −7 CMakeLists.txt
23 changes: 20 additions & 3 deletions nexa/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 36aa2cf

Please sign in to comment.