sugakrit6 commited on
Commit
76c7846
Β·
verified Β·
1 Parent(s): b7add04

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +65 -17
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="Finalizing model...")
280
 
281
- # Find the generated model file
282
- weights_dir = log_dir / "weights"
283
- model_files = list(weights_dir.glob("*.pth")) if weights_dir.exists() else []
 
 
 
 
 
284
 
285
- if model_files:
286
- latest_model = max(model_files, key=lambda p: p.stat().st_mtime)
287
-
288
- # Copy to output
 
 
 
 
 
 
 
 
 
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 index if exists
294
- index_files = list(log_dir.glob("*.index"))
 
 
 
 
 
 
 
295
  if index_files:
296
- shutil.copy2(index_files[0], output_dir)
 
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
- - {output_dir / f'{model_name}.pth'}
309
- - Index file (if generated)
310
 
311
- πŸŽ‰ Ready to download and use!
 
 
312
  """
313
  else:
314
- return "⚠️ Training completed but model file not found. Check logs directory."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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."