Update app.py
Browse files
app.py
CHANGED
|
@@ -276,27 +276,54 @@ Output: {result.stdout if result.stdout else 'Processing completed'}
|
|
| 276 |
|
| 277 |
process.wait()
|
| 278 |
|
| 279 |
-
progress(0.9, desc="
|
| 280 |
|
| 281 |
-
#
|
| 282 |
-
|
| 283 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
output_dir = self.workspace / model_name
|
| 290 |
output_dir.mkdir(exist_ok=True)
|
| 291 |
-
shutil.copy2(latest_model, output_dir / f"{model_name}.pth")
|
| 292 |
|
| 293 |
-
# Copy
|
| 294 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
if index_files:
|
| 296 |
-
|
|
|
|
| 297 |
|
| 298 |
progress(1.0, desc="Training complete!")
|
| 299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 300 |
return f"""β
Training Complete!
|
| 301 |
|
| 302 |
π Model: {model_name}
|
|
@@ -304,14 +331,35 @@ Output: {result.stdout if result.stdout else 'Processing completed'}
|
|
| 304 |
βοΈ Batch Size: {batch_size}
|
| 305 |
π΅ Sample Rate: {sample_rate}Hz
|
| 306 |
|
| 307 |
-
πΎ Model Files:
|
| 308 |
-
-
|
| 309 |
-
- Index file (if generated)
|
| 310 |
|
| 311 |
-
|
|
|
|
|
|
|
| 312 |
"""
|
| 313 |
else:
|
| 314 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
|
| 316 |
except Exception as e:
|
| 317 |
return f"β Training failed: {str(e)}\n\nNote: Real RVC training requires significant resources. Consider using Google Colab with GPU."
|
|
|
|
| 276 |
|
| 277 |
process.wait()
|
| 278 |
|
| 279 |
+
progress(0.9, desc="Searching for model files...")
|
| 280 |
|
| 281 |
+
# Search for model files in multiple possible locations
|
| 282 |
+
possible_paths = [
|
| 283 |
+
log_dir / "weights",
|
| 284 |
+
log_dir,
|
| 285 |
+
self.rvc_dir / "weights" / model_name,
|
| 286 |
+
self.rvc_dir / "logs" / model_name,
|
| 287 |
+
self.rvc_dir / "trained_models" / model_name,
|
| 288 |
+
]
|
| 289 |
|
| 290 |
+
model_files = []
|
| 291 |
+
for path in possible_paths:
|
| 292 |
+
if path.exists():
|
| 293 |
+
model_files.extend(list(path.glob("**/*.pth")))
|
| 294 |
+
|
| 295 |
+
# Also search for index files
|
| 296 |
+
index_files = []
|
| 297 |
+
for path in possible_paths:
|
| 298 |
+
if path.exists():
|
| 299 |
+
index_files.extend(list(path.glob("**/*.index")))
|
| 300 |
+
|
| 301 |
+
if model_files or index_files:
|
| 302 |
+
# Create output directory
|
| 303 |
output_dir = self.workspace / model_name
|
| 304 |
output_dir.mkdir(exist_ok=True)
|
|
|
|
| 305 |
|
| 306 |
+
# Copy model file
|
| 307 |
+
if model_files:
|
| 308 |
+
latest_model = max(model_files, key=lambda p: p.stat().st_mtime)
|
| 309 |
+
shutil.copy2(latest_model, output_dir / f"{model_name}.pth")
|
| 310 |
+
model_size = latest_model.stat().st_size / (1024*1024) # MB
|
| 311 |
+
else:
|
| 312 |
+
model_size = 0
|
| 313 |
+
|
| 314 |
+
# Copy index file
|
| 315 |
if index_files:
|
| 316 |
+
latest_index = max(index_files, key=lambda p: p.stat().st_mtime)
|
| 317 |
+
shutil.copy2(latest_index, output_dir / latest_index.name)
|
| 318 |
|
| 319 |
progress(1.0, desc="Training complete!")
|
| 320 |
|
| 321 |
+
files_info = []
|
| 322 |
+
if model_files:
|
| 323 |
+
files_info.append(f"- {model_name}.pth ({model_size:.1f}MB)")
|
| 324 |
+
if index_files:
|
| 325 |
+
files_info.append(f"- {latest_index.name}")
|
| 326 |
+
|
| 327 |
return f"""β
Training Complete!
|
| 328 |
|
| 329 |
π Model: {model_name}
|
|
|
|
| 331 |
βοΈ Batch Size: {batch_size}
|
| 332 |
π΅ Sample Rate: {sample_rate}Hz
|
| 333 |
|
| 334 |
+
πΎ Model Files Found:
|
| 335 |
+
{chr(10).join(files_info) if files_info else '- No files found'}
|
|
|
|
| 336 |
|
| 337 |
+
π Location: {output_dir}
|
| 338 |
+
|
| 339 |
+
π Ready to download!
|
| 340 |
"""
|
| 341 |
else:
|
| 342 |
+
# List what's in the log directory for debugging
|
| 343 |
+
debug_info = []
|
| 344 |
+
if log_dir.exists():
|
| 345 |
+
debug_info.append(f"Log directory exists: {log_dir}")
|
| 346 |
+
debug_info.append("Contents:")
|
| 347 |
+
for item in log_dir.rglob("*"):
|
| 348 |
+
debug_info.append(f" - {item.relative_to(log_dir)}")
|
| 349 |
+
|
| 350 |
+
return f"""β οΈ Training completed but model files not found.
|
| 351 |
+
|
| 352 |
+
π Searched in:
|
| 353 |
+
{chr(10).join([f'- {p}' for p in possible_paths])}
|
| 354 |
+
|
| 355 |
+
π Debug Info:
|
| 356 |
+
{chr(10).join(debug_info) if debug_info else 'Log directory not found'}
|
| 357 |
+
|
| 358 |
+
π‘ Possible issues:
|
| 359 |
+
- Training may have failed silently
|
| 360 |
+
- Model files saved to unexpected location
|
| 361 |
+
- Check the RVC logs directory manually
|
| 362 |
+
"""
|
| 363 |
|
| 364 |
except Exception as e:
|
| 365 |
return f"β Training failed: {str(e)}\n\nNote: Real RVC training requires significant resources. Consider using Google Colab with GPU."
|