Skip to content

Ryan5453/demucs

Repository files navigation

demucs-inference

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.

Installation

Prerequisites

FFmpeg

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 ffmpeg

UV

The 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"

Temporary Installation using UV

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.mp3

Note: 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 using UV

Install Demucs using the following command:

uv pip install demucs-inference --torch-backend=auto

The --torch-backend=auto flag automatically detects your GPU and installs the appropriate version of PyTorch compatible with your system.

Install without UV

Install Demucs using the following command:

pip install demucs-inference

Note: 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.

Usage

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/folder

Cog Usage

Demucs 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.

API Usage

Demucs provides a Python API for separating audio files. Please refer to the API docs for more information.

Changelog

The changelog contains information about the changes between versions of demucs-inference.

Footnotes

  1. You can use the Python API without FFmpeg, as you have the option to provide the audio as a Tensor.

About

Modern fork of demucs

Topics

Resources

License

Stars

Watchers

Forks

Languages