Code for the paper Hybrid Spectrogram and Waveform Source Separation

Related tags

Deep Learningdemucs
Overview

Demucs Music Source Separation

tests badge linter badge

This is the 3rd release of Demucs (v3), featuring hybrid source separation. For the waveform only Demucs (v2): Go this commit. If you are experiencing issues and want the old Demucs back, please fill an issue, and then you can get back to the v2 with git checkout v2.

We provide an implementation of Hybrid Demucs for music source separation, trained both on the MusDB HQ dataset, and with internal extra training data. They can separate drums, bass and vocals from the rest and achieved the first rank at the 2021 Sony Music DemiXing Challenge (MDX)

Demucs is based on U-Net convolutional architecture inspired by Wave-U-Net. The most recent version features hybrid spectrogram/waveform separation, along with compressed residual branches, local attention and singular value regularization. Checkout our paper Hybrid Spectrogram and Waveform Source Separation for more details. As far as we know, Demucs is currently the only model supporting true end-to-end hybrid model training with shared information between the domains, as opposed to post-training model blending.

When trained only on MusDB HQ, Hybrid Demucs achieved a SDR of 7.33 on the MDX test set, and 8.11 dB with 200 extra training tracks. It is particularly efficient for drums and bass extraction, although KUIELAB-MDX-Net performs better for vocals and other accompaniments.

Schema representing the structure of Demucs,
    with a dual U-Net structure with a shared core, one branch for the temporal domain,
    and one branch for the spectral domain.

Important news if you are already using Demucs

See the release notes for more details.

  • 12/11/2021: Releasing Demucs v3 with hybrid domain separation. Strong improvements on all sources. This is the model that won Sony MDX challenge.
  • 11/05/2021: Adding support for MusDB-HQ and arbitrary wav set, for the MDX challenge. For more information on joining the challenge with Demucs see the Demucs MDX instructions
  • 28/04/2021: Demucs v2, with extra augmentation and DiffQ based quantization. EVERYTHING WILL BREAK, please restart from scratch following the instructions hereafter. This version also adds overlap between prediction frames, with linear transition from one to the next, which should prevent sudden changes at frame boundaries. Also, Demucs is now on PyPI, so for separation only, installation is as easy as pip install demucs :)
  • 13/04/2020: Demucs released under MIT: We are happy to release Demucs under the MIT licence. We hope that this will broaden the impact of this research to new applications.

Comparison with other models

We provide hereafter a summary of the different metrics presented in the paper. You can also compare Hybrid Demucs (v3), KUIELAB-MDX-Net, Spleeter, Open-Unmix, Demucs (v1), and Conv-Tasnet on one of my favorite songs on my soundcloud playlist.

Comparison of accuracy

Overall SDR is the mean of the SDR for each of the 4 sources, MOS Quality is a rating from 1 to 5 of the naturalness and absence of artifacts given by human listeners (5 = no artifacts), MOS Contamination is a rating from 1 to 5 with 5 being zero contamination by other sources. We refer the reader to our paper, for more details.

Model Domain Extra data? Overall SDR MOS Quality MOS Contamination
Wave-U-Net waveform no 3.2 - -
Open-Unmix spectrogram no 5.3 - -
D3Net spectrogram no 6.0 - -
Conv-Tasnet waveform no 5.7 -
Demucs (v2) waveform no 6.3 2.37 2.36
ResUNetDecouple+ spectrogram no 6.7 - -
KUIELAB-MDX-Net hybrid no 7.5 2.86 2.55
Hybrid Demucs (v3) hybrid no 7.7 2.83 3.04
MMDenseLSTM spectrogram 804 songs 6.0 - -
D3Net spectrogram 1.5k songs 6.7 - -
Spleeter spectrogram 25k songs 5.9 - -

Requirements

You will need at least Python 3.7. See requirements_minimal.txt for requirements for separation only, and environment-[cpu|cuda].yml (or requirements.txt) if you want to train a new model.

For Windows users

Everytime you see python3, replace it with python.exe. You should always run commands from the Anaconda console.

For musicians

If you just want to use Demucs to separate tracks, you can install it with

python3 -m pip -U install demucs

Advanced OS support are provided on the following page, you must read the page for your OS before posting an issues:

For machine learning scientists

If you have anaconda installed, you can run from the root of this repository:

conda env update -f environment-cpu.yml  # if you don't have GPUs
conda env update -f environment-cuda.yml # if you have GPUs
conda activate demucs
pip install -e .

This will create a demucs environment with all the dependencies installed.

You will also need to install soundstretch/soundtouch: on Mac OSX you can do brew install sound-touch, and on Ubuntu sudo apt-get install soundstretch. This is used for the pitch/tempo augmentation.

Running in Docker

Thanks to @xserrat, there is now a Docker image definition ready for using Demucs. This can ensure all libraries are correctly installed without interfering with the host OS. See his repo Docker Facebook Demucs for more information.

Running from Colab

I made a Colab to easily separate track with Demucs. Note that transfer speeds with Colab are a bit slow for large media files, but it will allow you to use Demucs without installing anything.

Demucs on Google Colab

Web Demo

(Possibly broken with the update, need to investigate) Integrated to Huggingface Spaces with Gradio. See demo: Hugging Face Spaces

Separating tracks

In order to try Demucs, you can just run from any folder (as long as you properly installed it)

demucs PATH_TO_AUDIO_FILE_1 [PATH_TO_AUDIO_FILE_2 ...]   # for Demucs
# If you used `pip install --user` you might need to replace demucs with python3 -m demucs
python3 -m demucs --mp3 --mp3-bitrate BITRATE PATH_TO_AUDIO_FILE_1  # output files saved as MP3
# If your filename contain spaces don't forget to quote it !!!
demucs "my music/my favorite track.mp3"
# You can select different models with `-n` mdx_q is the quantized model, smaller but maybe a bit less accurate.
demucs -n mdx_q myfile.mp3

If you have a GPU, but you run out of memory, please add -d cpu to the command line. See the section hereafter for more details on the memory requirements for GPU acceleration.

Separated tracks are stored in the separated/MODEL_NAME/TRACK_NAME folder. There you will find four stereo wav files sampled at 44.1 kHz: drums.wav, bass.wav, other.wav, vocals.wav (or .mp3 if you used the --mp3 option).

All audio formats supported by torchaudio can be processed (i.e. wav, mp3, flac, ogg/vorbis on Linux/Mac OS X etc.). On Windows, torchaudio has limited support, so we rely on ffmpeg, which should support pretty much anything. Audio is resampled on the fly if necessary. The output will be a wave file, either in int16 format or float32 (if --float32 is passed). You can pass --mp3 to save as mp3 instead, and set the bitrate with --mp3-bitrate (default is 320kbps).

Other pre-trained models can be selected with the -n flag. The list of pre-trained models is:

  • mdx: trained only on MusDB HQ, winning model on track A at the MDX challenge.
  • mdx_extra: trained with extra training data (including MusDB test set), ranked 2nd on the track B of the MDX challenge.
  • mdx_q, mdx_extra_q: quantized version of the previous models. Smaller download and storage but quality can be slightly worse. mdx_extra_q is the default model used.
  • SIG: where SIG is a single model from the model zoo.

The --shifts=SHIFTS performs multiple predictions with random shifts (a.k.a the shift trick) of the input and average them. This makes prediction SHIFTS times slower. Don't use it unless you have a GPU.

The --overlap option controls the amount of overlap between prediction windows (for Demucs one window is 10 seconds). Default is 0.25 (i.e. 25%) which is probably fine.

Memory requirements for GPU acceleration

If you want to use GPU acceleration, you will need at least 8GB of RAM on your GPU for demucs. Sorry, the code for demucs is not super optimized for memory! If you do not have enough memory on your GPU, simply add -d cpu to the command line to use the CPU. With Demucs, processing time should be roughly equal to 1.5 times the duration of the track.

Training Demucs

If you want to train (Hybrid) Demucs, please follow the training doc.

MDX Challenge reproduction

In order to reproduce the results from the Track A and Track B submissions, checkout the MDX Hybrid Demucs submission repo.

How to cite

@inproceedings{defossez2021hybrid,
  title={Hybrid Spectrogram and Waveform Source Separation},
  author={D{\'e}fossez, Alexandre},
  booktitle={Proceedings of the ISMIR 2021 Workshop on Music Source Separation},
  year={2021}
}

License

Demucs is released under the MIT license as found in the LICENSE file.

Owner
Meta Research
Meta Research
Vision-Language Transformer and Query Generation for Referring Segmentation (ICCV 2021)

Vision-Language Transformer and Query Generation for Referring Segmentation Please consider citing our paper in your publications if the project helps

Henghui Ding 143 Dec 23, 2022
A python comtrade load library accelerated by go

Comtrade-GRPC Code for python used is mainly from dparrini/python-comtrade. Just patch the code in BinaryDatReader.parse for parsing a little more eff

Bo 1 Dec 27, 2021
A multi-functional library for full-stack Deep Learning. Simplifies Model Building, API development, and Model Deployment.

chitra What is chitra? chitra (चित्र) is a multi-functional library for full-stack Deep Learning. It simplifies Model Building, API development, and M

Aniket Maurya 210 Dec 21, 2022
This is the official Pytorch-version code of FlatGCN (Flattened Graph Convolutional Networks for Recommendation).

FlatGCN This is the official Pytorch-version code of FlatGCN (Flattened Graph Convolutional Networks for Recommendation, submitted to ICASSP2022). Req

Dreamer 2 Aug 09, 2022
End-to-End Object Detection with Fully Convolutional Network

This project provides an implementation for "End-to-End Object Detection with Fully Convolutional Network" on PyTorch.

472 Dec 22, 2022
Small repo describing how to use Hugging Face's Wav2Vec2 with PyCTCDecode

🤗 Transformers Wav2Vec2 + PyCTCDecode Introduction This repo shows how 🤗 Transformers can be used in combination with kensho-technologies's PyCTCDec

Patrick von Platen 102 Oct 22, 2022
PyTorch implementation of Weak-shot Fine-grained Classification via Similarity Transfer

SimTrans-Weak-Shot-Classification This repository contains the official PyTorch implementation of the following paper: Weak-shot Fine-grained Classifi

BCMI 60 Dec 02, 2022
Hunt down social media accounts by username across social networks

Hunt down social media accounts by username across social networks Installation | Usage | Docker Notes | Contributing Installation # clone the repo $

1 Dec 14, 2021
基于Paddlepaddle复现yolov5,支持PaddleDetection接口

PaddleDetection yolov5 https://github.com/Sharpiless/PaddleDetection-Yolov5 简介 PaddleDetection飞桨目标检测开发套件,旨在帮助开发者更快更好地完成检测模型的组建、训练、优化及部署等全开发流程。 PaddleD

36 Jan 07, 2023
MoCoGAN: Decomposing Motion and Content for Video Generation

MoCoGAN: Decomposing Motion and Content for Video Generation This repository contains an implementation and further details of MoCoGAN: Decomposing Mo

Sergey Tulyakov 514 Dec 18, 2022
NATS-Bench: Benchmarking NAS Algorithms for Architecture Topology and Size

NATS-Bench: Benchmarking NAS Algorithms for Architecture Topology and Size Xuanyi Dong, Lu Liu, Katarzyna Musial, Bogdan Gabrys in IEEE Transactions o

D-X-Y 137 Dec 20, 2022
Implementation for Simple Spectral Graph Convolution in ICLR 2021

Simple Spectral Graph Convolutional Overview This repo contains an example implementation of the Simple Spectral Graph Convolutional (S^2GC) model. Th

allenhaozhu 64 Dec 31, 2022
Context-Aware Image Matting for Simultaneous Foreground and Alpha Estimation

Context-Aware Image Matting for Simultaneous Foreground and Alpha Estimation This is the inference codes of Context-Aware Image Matting for Simultaneo

Qiqi Hou 125 Oct 22, 2022
Implementation of [Time in a Box: Advancing Knowledge Graph Completion with Temporal Scopes].

Time2box Implementation of [Time in a Box: Advancing Knowledge Graph Completion with Temporal Scopes].

LingCai 4 Aug 23, 2022
This repository is for the preprint "A generative nonparametric Bayesian model for whole genomes"

BEAR Overview This repository contains code associated with the preprint A generative nonparametric Bayesian model for whole genomes (2021), which pro

Debora Marks Lab 10 Sep 18, 2022
Image Classification - A research on image classification and auto insurance claim prediction, a systematic experiments on modeling techniques and approaches

A research on image classification and auto insurance claim prediction, a systematic experiments on modeling techniques and approaches

0 Jan 23, 2022
Rank1 Conversation Emotion Detection Task

Rank1-Conversation_Emotion_Detection_Task accuracy macro-f1 recall 0.826 0.7544 0.719 基于预训练模型和时序预测模型的对话情感探测任务 1 摘要 针对对话情感探测任务,本文将其分为文本分类和时间序列预测两个子任务,分

Yuchen Han 2 Nov 28, 2021
State-to-Distribution (STD) Model

State-to-Distribution (STD) Model In this repository we provide exemplary code on how to construct and evaluate a state-to-distribution (STD) model fo

<a href=[email protected]"> 2 Apr 07, 2022
Let Python optimize the best stop loss and take profits for your TradingView strategy.

TradingView Machine Learning TradeView is a free and open source Trading View bot written in Python. It is designed to support all major exchanges. It

Robert Roman 473 Jan 09, 2023
SPT_LSA_ViT - Implementation for Visual Transformer for Small-size Datasets

Vision Transformer for Small-Size Datasets Seung Hoon Lee and Seunghyun Lee and Byung Cheol Song | Paper Inha University Abstract Recently, the Vision

Lee SeungHoon 87 Jan 01, 2023