Warning
demucs-inference is still in an alpha state and is not recommended for production use. A stable release will be released soon.
Demucs is a state-of-the-art music source separation model capable of separating drums, bass, and vocals from the rest of the accompaniment. This is a fork of the author's fork of the original Demucs repository. It has been updated to use modern versions of Python, PyTorch, and TorchCodec.
Demucs requires1 FFmpeg v4+ to be installed on your system. You can install it using the following command:
# macOS
brew install ffmpeg
# Ubuntu/Debian
sudo apt-get install ffmpeg
# Windows
choco install ffmpegThe recommended way to install demucs-inference is to use UV. You can install it using the following command:
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows PowerShell
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"With UV, you can use the uvx command to run Demucs without installing it permanently on your system. This sets up a temporary virtual enviornment for the duration of the command.
uvx demucs-inference separate audio_file.mp3Note: Demucs does not specify a specific PyTorch wheel. This means that GPUs will only work on Apple Silicon or PyTorch's default CUDA version (currently 12.8) on Linux when using uvx. Demucs will fall back to CPU if one of the above conditions are not met.
Install Demucs using the following command:
uv pip install demucs-inference --torch-backend=autoThe --torch-backend=auto flag automatically detects your GPU and installs the appropriate version of PyTorch compatible with your system.
Install Demucs using the following command:
pip install demucs-inferenceNote: Demucs does not specify a specific PyTorch wheel. If you want to use a GPU, view the PyTorch installation guide and append the correct index URL.
After installing Demucs, you can use it like the following:
# View separation options
demucs separate --help
# Separate one audio file
demucs separate audio_file.mp3
# Separate multiple audio files
demucs separate audio_file_1.mp3 audio_file_2.mp3
# Separate all audio files in a directory
demucs separate /path/to/music/folderDemucs provides a Cog, which allows you to easily deploy a Demucs model as a REST API. You can alternatively use the hosted version at Replicate.
Demucs provides a Python API for separating audio files. Please refer to the API docs for more information.
The changelog contains information about the changes between versions of demucs-inference.
Footnotes
-
You can use the Python API without FFmpeg, as you have the option to provide the audio as a Tensor. ↩