facebookresearch / demucs

Code for the paper Hybrid Spectrogram and Waveform Source Separation
MIT License
8.38k stars 1.07k forks source link

Demucs won't read variables #619

Closed CerealWeb1109 closed 4 weeks ago

CerealWeb1109 commented 4 weeks ago

🐛 Bug Report

When specifying input file for demucs using variable "{segment_file}", get response: Selected model is a bag of 1 models. You will see that many progress bars per track. Separated tracks will be stored in /content/separated/htdemucs File {segment_file} does not exist. If the path contains spaces, please try again after surrounding the entire path with quotes "". I tried different ways, without double quotations: segment_file = '/content/audio.mp3' !demucs {segmentfile} --filename "stems/{track}{stem}.{ext}" still get the same error

To Reproduce

  1. Connect to Google Colab T4 GPU runtime
  2. Upload any audio file
  3. Run this command: !pip install demucs
  4. Copy and paste this into a cell and run it: segment_file = '/content/audio.mp3' !demucs "{segmentfile}" --filename "stems/{track}{stem}.{ext}"

Expected behavior

Successfull stem seperation

Actual Behavior

Got the following output: Selected model is a bag of 1 models. You will see that many progress bars per track. Separated tracks will be stored in /content/separated/htdemucs File {segment_file} does not exist. If the path contains spaces, please try again after surrounding the entire path with quotes "".

Your Environment

Google Colab Runtime OS: Linux-6.1.85+-x86_64-with-glibc2.35 Python version: 3.10.12 Demucs installation: Python package, installed using !pip install demucs. Demucs version: 4.0.1

CerealWeb1109 commented 4 weeks ago

Okay, the problem is only when I use the filename argument, but i still don't know why thats the case. If i use other arguments like !demucs {segment_file} --two-stems=vocals it works fine. Probably something to do with the predefined variables messing up with my variable

CarlGao4 commented 4 weeks ago

In IPython (and Jupyter Notebook), inputs starting with exclamation mark (!) will be processed like this:

  1. Run eval for everything inside braces
  2. If one fails, then all braces will be ignored and the command will be passed directly

Some examples:

In [ ]: # Something could be evaluated
   ...: !echo {123}
123

In [ ]: # Defined variables
   ...: a = "Hello"
   ...: !echo {a}
Hello

In [ ]: # Undefined variables
   ...: !echo {b}
{b}

In [ ]: # Defined and undefined variables in the same command
   ...: !echo {a} {world}
{a} {world}

In [ ]: # The we can output something with braces and evaluate defined variables at the same time
   ...: !echo {a} {{world}}
Hello {world}
CerealWeb1109 commented 4 weeks ago

@CarlGao4 I see. Using double curly brackets worked for me: segment_file = 'audio.mp3' !demucs {segmentfile} --out /content/stems/ --filename '{{track}}{{stem}}.{{ext}}' the outputs were saved as /content/stems/audio_bass.wav, /content/stems/audio_vocals.wav...