Add --remove-model option to remove models from local database

- Can remove by numeric ID (from --model-list) or by name
- Also supports removing by HuggingFace model ID
- Updates models.json after removal
parent 3d576732
...@@ -7181,6 +7181,51 @@ def main(args): ...@@ -7181,6 +7181,51 @@ def main(args):
print(f" Use with: --model {name}") print(f" Use with: --model {name}")
sys.exit(0) sys.exit(0)
# Handle model removal
if args.remove_model:
# Support both numeric ID and name
model_to_remove = args.remove_model
removed = False
# Check if it's a numeric ID
if model_to_remove.isdigit():
idx = int(model_to_remove)
sorted_models = sorted(MODELS.items())
if 1 <= idx <= len(sorted_models):
name = sorted_models[idx - 1][0]
model_id = MODELS[name].get("id", name)
del MODELS[name]
save_models_config(MODELS)
print(f"✅ Model removed: {name} ({model_id})")
removed = True
else:
print(f"❌ Invalid model ID: {idx}. Use --model-list to see available IDs.")
else:
# Try to remove by name
if model_to_remove in MODELS:
model_id = MODELS[model_to_remove].get("id", model_to_remove)
del MODELS[model_to_remove]
save_models_config(MODELS)
print(f"✅ Model removed: {model_to_remove} ({model_id})")
removed = True
else:
# Try to find by model ID
found_name = None
for name, info in MODELS.items():
if info.get("id") == model_to_remove:
found_name = name
break
if found_name:
del MODELS[found_name]
save_models_config(MODELS)
print(f"✅ Model removed: {found_name} ({model_to_remove})")
removed = True
if not removed:
print(f"❌ Model not found: {model_to_remove}")
print(f" Use --model-list to see available models")
sys.exit(0)
# Handle model validation # Handle model validation
if args.validate_model: if args.validate_model:
hf_token = os.environ.get("HF_TOKEN") hf_token = os.environ.get("HF_TOKEN")
...@@ -9105,6 +9150,9 @@ List TTS voices: ...@@ -9105,6 +9150,9 @@ List TTS voices:
parser.add_argument("--validate-model", type=str, default=None, parser.add_argument("--validate-model", type=str, default=None,
metavar="MODEL_ID", metavar="MODEL_ID",
help="Validate if a HuggingFace model exists and get info") help="Validate if a HuggingFace model exists and get info")
parser.add_argument("--remove-model", type=str, default=None,
metavar="ID_OR_NAME",
help="Remove a model from the local database by numeric ID (from --model-list) or name")
parser.add_argument("--update-models", action="store_true", parser.add_argument("--update-models", action="store_true",
help="Search HuggingFace and update model database with I2V, T2V, and NSFW models") help="Search HuggingFace and update model database with I2V, T2V, and NSFW models")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment