Spaces:
Sleeping
Sleeping
update models.py
Browse files- modules/models.py +19 -2
modules/models.py
CHANGED
|
@@ -256,8 +256,25 @@ def load_embedder(emb_file: str, emb_name: str):
|
|
| 256 |
|
| 257 |
|
| 258 |
def get_vc_model(model_name: str):
|
| 259 |
-
model_path = os.path.join(MODELS_DIR, "checkpoints", model_name)
|
| 260 |
-
weight = torch.load(model_path, map_location="cpu")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
return VoiceConvertModel(model_name, weight)
|
| 262 |
|
| 263 |
|
|
|
|
| 256 |
|
| 257 |
|
| 258 |
def get_vc_model(model_name: str):
|
| 259 |
+
# model_path = os.path.join(MODELS_DIR, "checkpoints", model_name)
|
| 260 |
+
# weight = torch.load(model_path, map_location="cpu")
|
| 261 |
+
|
| 262 |
+
# Handle relative paths (e.g., "weights/zet_test1.pth")
|
| 263 |
+
if "/" in model_name:
|
| 264 |
+
# It's a relative path, use it directly
|
| 265 |
+
model_path = os.path.join(ROOT_DIR, model_name)
|
| 266 |
+
if not os.path.exists(model_path):
|
| 267 |
+
raise FileNotFoundError(f"Model file not found: {model_path}")
|
| 268 |
+
else:
|
| 269 |
+
# It's just a filename, check in weights folder first (for custom models)
|
| 270 |
+
weights_path = os.path.join(ROOT_DIR, "weights", model_name)
|
| 271 |
+
if os.path.exists(weights_path):
|
| 272 |
+
model_path = weights_path
|
| 273 |
+
else:
|
| 274 |
+
# Fallback to checkpoints folder
|
| 275 |
+
model_path = os.path.join(MODELS_DIR, "checkpoints", model_name)
|
| 276 |
+
|
| 277 |
+
weight = torch.load(model_path, map_location="cpu", weights_only=False)
|
| 278 |
return VoiceConvertModel(model_name, weight)
|
| 279 |
|
| 280 |
|