ASesYusuf1 commited on
Commit
f9159bd
·
verified ·
1 Parent(s): 24e39e6

Update audio_separator/separator/separator.py

Browse files
audio_separator/separator/separator.py CHANGED
@@ -582,6 +582,35 @@ class Separator:
582
  """
583
  model_path = os.path.join(self.model_file_dir, f"{model_filename}")
584
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
585
  supported_model_files_grouped = self.list_supported_model_files()
586
  public_model_repo_url_prefix = "https://github.com/TRvlvr/model_repo/releases/download/all_public_uvr_models"
587
  vip_model_repo_url_prefix = "https://github.com/Anjok0109/ai_magic/releases/download/v5"
 
582
  """
583
  model_path = os.path.join(self.model_file_dir, f"{model_filename}")
584
 
585
+ # BYPASS: If the model file already exists locally (pre-downloaded), skip the registry check entirely.
586
+ # This allows custom/non-registered models to be loaded without being in UVR's supported model list.
587
+ if os.path.isfile(model_path):
588
+ self.logger.info(f"Model file already exists at {model_path}, skipping registry lookup (bypass active)")
589
+ yaml_config_filename = None
590
+ model_basename = model_filename.rsplit('.', 1)[0]
591
+ # Try to find a matching YAML config file in the model directory
592
+ try:
593
+ for f in os.listdir(self.model_file_dir):
594
+ if f.endswith('.yaml') and not f.startswith('model_data') and f != 'download_checks.json':
595
+ # Prefer YAML files that share a name prefix with the model
596
+ if model_basename in f or f.replace('.yaml', '') in model_basename:
597
+ yaml_config_filename = f
598
+ break
599
+ # If no exact match, try any YAML that was recently modified (likely downloaded together)
600
+ if yaml_config_filename is None:
601
+ yaml_files = [f for f in os.listdir(self.model_file_dir) if f.endswith('.yaml') and not f.startswith('model_data')]
602
+ if yaml_files:
603
+ # Sort by modification time, newest first
604
+ yaml_files.sort(key=lambda x: os.path.getmtime(os.path.join(self.model_file_dir, x)), reverse=True)
605
+ yaml_config_filename = yaml_files[0]
606
+ except Exception as e:
607
+ self.logger.warning(f"Error scanning for YAML config: {e}")
608
+
609
+ self.model_friendly_name = model_filename
610
+ model_type = "MDXC" # MDXC type uses YAML-based config loading, bypassing hash check
611
+ self.logger.info(f"Bypass: Using model_type={model_type}, yaml_config={yaml_config_filename}")
612
+ return model_filename, model_type, model_filename, model_path, yaml_config_filename
613
+
614
  supported_model_files_grouped = self.list_supported_model_files()
615
  public_model_repo_url_prefix = "https://github.com/TRvlvr/model_repo/releases/download/all_public_uvr_models"
616
  vip_model_repo_url_prefix = "https://github.com/Anjok0109/ai_magic/releases/download/v5"