helloWorld199 commited on
Commit
90a0767
1 Parent(s): 11bbba7

Upload 2 files

Browse files
Files changed (2) hide show
  1. src/main.py +1 -1
  2. src/mdx.py +8 -3
src/main.py CHANGED
@@ -181,7 +181,7 @@ def preprocess_song(song_input, mdx_model_params, song_id, is_webui, input_type,
181
  orig_song_path = convert_to_stereo(orig_song_path)
182
 
183
  display_progress('[~] Separating Vocals from Instrumental...', 0.1, is_webui, progress)
184
- vocals_path, instrumentals_path = run_mdx(mdx_model_params, song_output_dir, os.path.join(mdxnet_models_dir, 'UVR-MDX-NET-Voc_FT.onnx'), orig_song_path, denoise=True, keep_orig=keep_orig, _stemname1 = "_origvocals", _stemname2 = "_originstr")
185
 
186
  display_progress('[~] Separating Main Vocals from Backup Vocals...', 0.2, is_webui, progress)
187
  backup_vocals_path, main_vocals_path = run_mdx(mdx_model_params, song_output_dir, os.path.join(mdxnet_models_dir, 'UVR_MDXNET_KARA_2.onnx'), vocals_path, suffix='Backup', invert_suffix='Main', denoise=True)
 
181
  orig_song_path = convert_to_stereo(orig_song_path)
182
 
183
  display_progress('[~] Separating Vocals from Instrumental...', 0.1, is_webui, progress)
184
+ vocals_path, instrumentals_path = run_mdx(mdx_model_params, song_output_dir, os.path.join(mdxnet_models_dir, 'UVR-MDX-NET-Voc_FT.onnx'), orig_song_path, denoise=True, keep_orig=keep_orig, _stemname1 = "_origvocals", _stemname2="_originstr")
185
 
186
  display_progress('[~] Separating Main Vocals from Backup Vocals...', 0.2, is_webui, progress)
187
  backup_vocals_path, main_vocals_path = run_mdx(mdx_model_params, song_output_dir, os.path.join(mdxnet_models_dir, 'UVR_MDXNET_KARA_2.onnx'), vocals_path, suffix='Backup', invert_suffix='Main', denoise=True)
src/mdx.py CHANGED
@@ -65,9 +65,11 @@ class MDX:
65
  def __init__(self, model_path: str, params: MDXModel, processor=DEFAULT_PROCESSOR):
66
 
67
  # Set the device and the provider (CPU or CUDA)
68
- self.device = torch.device(f'cuda:{processor}') if processor >= 0 else torch.device('cpu')
69
- self.provider = ['CUDAExecutionProvider'] if processor >= 0 else ['CPUExecutionProvider']
70
-
 
 
71
  self.model = params
72
 
73
  # Load the ONNX model using ONNX Runtime
@@ -166,6 +168,8 @@ class MDX:
166
  waves = np.array(wave_p[:, i:i + self.model.chunk_size])
167
  mix_waves.append(waves)
168
 
 
 
169
  mix_waves = torch.tensor(mix_waves, dtype=torch.float32).to(self.device)
170
 
171
  return mix_waves, pad, trim
@@ -285,3 +289,4 @@ def run_mdx(model_params, output_dir, model_path, filename, exclude_main=False,
285
  del mdx_sess, wave_processed, wave
286
  gc.collect()
287
  return main_filepath, invert_filepath
 
 
65
  def __init__(self, model_path: str, params: MDXModel, processor=DEFAULT_PROCESSOR):
66
 
67
  # Set the device and the provider (CPU or CUDA)
68
+ #self.device = torch.device(f'cuda:{processor}') if processor >= 0 else torch.device('cpu')
69
+ self.device = torch.device('cuda:0') if torch.cuda.is_available() else torch.device('cpu')
70
+ #self.provider = ['CUDAExecutionProvider'] if processor >= 0 else ['CPUExecutionProvider']
71
+ self.provider = ['CPUExecutionProvider']
72
+
73
  self.model = params
74
 
75
  # Load the ONNX model using ONNX Runtime
 
168
  waves = np.array(wave_p[:, i:i + self.model.chunk_size])
169
  mix_waves.append(waves)
170
 
171
+ print(self.device)
172
+
173
  mix_waves = torch.tensor(mix_waves, dtype=torch.float32).to(self.device)
174
 
175
  return mix_waves, pad, trim
 
289
  del mdx_sess, wave_processed, wave
290
  gc.collect()
291
  return main_filepath, invert_filepath
292
+