From 3b640103bcc91946719f17716754130542fa34d0 Mon Sep 17 00:00:00 2001 From: Paul Sajna Date: Sat, 13 May 2023 20:00:55 -0700 Subject: [PATCH] add requirements.txt, remove debug prints --- stem_separation/.gitignore | 1 + stem_separation/MDX Arch/infer.py | 12 +++++++++--- stem_separation/VR Arch/infer.py | 2 -- stem_separation/VR Arch/spec_utils.py | 22 +++++++++++----------- stem_separation/requirements.txt | 8 ++++++++ 5 files changed, 29 insertions(+), 16 deletions(-) create mode 100644 stem_separation/requirements.txt diff --git a/stem_separation/.gitignore b/stem_separation/.gitignore index 7470c36..87f93cd 100644 --- a/stem_separation/.gitignore +++ b/stem_separation/.gitignore @@ -2,3 +2,4 @@ *.wav *.pt *.pth +env/ diff --git a/stem_separation/MDX Arch/infer.py b/stem_separation/MDX Arch/infer.py index 49df323..c1296a4 100644 --- a/stem_separation/MDX Arch/infer.py +++ b/stem_separation/MDX Arch/infer.py @@ -18,7 +18,13 @@ class MDXModel: self.window = torch.hann_window(self.n_fft) self.freq_pad = torch.zeros([1, self.dim_c, self.n_bins-self.dim_f, self.dim_t]) self.adjust = 1 - self.ort_ = ort.InferenceSession("models/" + model_file) + self.ort_ = ort.InferenceSession( + "models/" + model_file, + providers=[ + "CUDAExecutionProvider", + "CPUExecutionProvider" + ] + ) self.model_run = lambda spek:self.ort_.run(None, {'input': spek})[0] @@ -100,5 +106,5 @@ class ReverbHQ(MDXModel): if __name__ == "__main__": - ReverbHQ().process("/mnt/8terra/tts/voice-conversion-sources/eyeofthetiger.wav", "/tmp/stem1.wav", "/tmp/stem2.wav") - #MDXNetMain().process("/tmp/Carly Rae Jepsen - Call Me Maybe [fWNaR-rxAic].webm", "stem1.wav", "stem2.wav") + #ReverbHQ().process("/mnt/8terra/tts/voice-conversion-sources/eyeofthetiger.wav", "/tmp/stem1.wav", "/tmp/stem2.wav") + MDXNetMain().process("/tmp/Carly Rae Jepsen - Call Me Maybe [fWNaR-rxAic].webm", "stem1.wav", "stem2.wav") diff --git a/stem_separation/VR Arch/infer.py b/stem_separation/VR Arch/infer.py index b798198..84139ff 100644 --- a/stem_separation/VR Arch/infer.py +++ b/stem_separation/VR Arch/infer.py @@ -56,14 +56,12 @@ class VR_Arch: self.primary_source = spec_utils.normalize(self.spec_to_wav(y_spec), self.is_normalization).T if not self.model_samplerate == 44100: self.primary_source = librosa.resample(self.primary_source.T, orig_sr=self.model_samplerate, target_sr=44100) - print(self.primary_source.shape) torchaudio.save(primary_stem_path, torch.from_numpy(self.primary_source).float().T, 44100) self.secondary_source = self.spec_to_wav(v_spec) self.secondary_source = spec_utils.normalize(self.spec_to_wav(v_spec), self.is_normalization).T if not self.model_samplerate == 44100: self.secondary_source = librosa.resample(self.secondary_source.T, orig_sr=self.model_samplerate, target_sr=44100) - print(self.secondary_source.shape) torchaudio.save(secondary_stem_path, torch.from_numpy(self.secondary_source).float().T, 44100) torch.cuda.empty_cache() diff --git a/stem_separation/VR Arch/spec_utils.py b/stem_separation/VR Arch/spec_utils.py index dba7526..c148610 100644 --- a/stem_separation/VR Arch/spec_utils.py +++ b/stem_separation/VR Arch/spec_utils.py @@ -112,14 +112,14 @@ def normalize(wave, is_normalize=False): """Save output music files""" maxv = np.abs(wave).max() if maxv > 1.0: - print(f"\nNormalization Set {is_normalize}: Input above threshold for clipping. Max:{maxv}") + #print(f"\nNormalization Set {is_normalize}: Input above threshold for clipping. Max:{maxv}") if is_normalize: - print(f"The result was normalized.") + # print(f"The result was normalized.") wave /= maxv else: - print(f"The result was not normalized.") + # print(f"The result was not normalized.") else: - print(f"\nNormalization Set {is_normalize}: Input not above threshold for clipping. Max:{maxv}") + #print(f"\nNormalization Set {is_normalize}: Input not above threshold for clipping. Max:{maxv}") return wave @@ -130,20 +130,20 @@ def normalize_two_stem(wave, mix, is_normalize=False): max_mix = np.abs(mix).max() if maxv > 1.0: - print(f"\nNormalization Set {is_normalize}: Primary source above threshold for clipping. Max:{maxv}") - print(f"\nNormalization Set {is_normalize}: Mixture above threshold for clipping. Max:{max_mix}") + #print(f"\nNormalization Set {is_normalize}: Primary source above threshold for clipping. Max:{maxv}") + #print(f"\nNormalization Set {is_normalize}: Mixture above threshold for clipping. Max:{max_mix}") if is_normalize: - print(f"The result was normalized.") + #print(f"The result was normalized.") wave /= maxv mix /= maxv else: - print(f"The result was not normalized.") + #print(f"The result was not normalized.") else: - print(f"\nNormalization Set {is_normalize}: Input not above threshold for clipping. Max:{maxv}") + #print(f"\nNormalization Set {is_normalize}: Input not above threshold for clipping. Max:{maxv}") - print(f"\nNormalization Set {is_normalize}: Primary source - Max:{np.abs(wave).max()}") - print(f"\nNormalization Set {is_normalize}: Mixture - Max:{np.abs(mix).max()}") + #print(f"\nNormalization Set {is_normalize}: Primary source - Max:{np.abs(wave).max()}") + #print(f"\nNormalization Set {is_normalize}: Mixture - Max:{np.abs(mix).max()}") return wave, mix diff --git a/stem_separation/requirements.txt b/stem_separation/requirements.txt new file mode 100644 index 0000000..e29b06f --- /dev/null +++ b/stem_separation/requirements.txt @@ -0,0 +1,8 @@ +librosa==0.9.2 +torch==2.0.1 +torchaudio==2.0.2 +onnxruntime-gpu==1.14.1 +numpy==1.23.5 +six==1.16.0 +soundfile==0.12.1 +samplerate==0.1.0