Music Demixing Challenge ISMIR 2021
🚀 Make your submissions from inside Google Colab
Explore different baselines and make your submission
Dear participants,
Check out the Colab notebook below, and get started with the challenge easily, right from inside Google Colab!
Let us know if you face any issues or want to share any feedback.
How to use this notebook 📝¶
- Copy the notebook. This is a shared template and any edits you make here will not be saved. You should copy it into your own drive folder. For this, click the "File" menu (top-left), then "Save a Copy in Drive". You can edit your copy however you like.
- Link it to your AIcrowd account. In order to submit your code to AIcrowd, you need to add ssh key to your GitLab account temporarily.
- Stick to the classes definitions. The submission to AIcrowd will look for the pre-defined class names.
Setup the notebook 🛠¶
!pip install -q -U "tqdm<4.60"
!apt install git-lfs
!git clone https://github.com/AIcrowd/music-demixing-challenge-starter-kit.git > /dev/null
%cd music-demixing-challenge-starter-kit
!git lfs pull
👇 Run the below collapsed cell for helper functions¶
#@title
import os
import IPython
import pprint
def display_result(path):
print(path)
print("🔈 Bass:")
display(IPython.display.Audio(path + "/bass.wav"))
print("🥁 Drums:")
display(IPython.display.Audio(path + "/drums.wav"))
print("🎹 Other:")
display(IPython.display.Audio(path + "/other.wav"))
print("🎤 Vocals:")
display(IPython.display.Audio(path + "/vocals.wav"))
def install_pip_and_apt_on_colab():
default_requirements = open("requirements.txt").read().split('\n')
local_pip_install = " ".join(default_requirements + PIP_PACKAGES)
default_packages = open("apt.txt").read().split('\n')
local_apt_install = " ".join(default_packages + APT_PACKAGES)
!pip install -q $local_pip_install
!apt install -y {local_apt_install}
def write_custom_implementation(file_name):
relevant_cell = None
for i in _ih[::-1]:
if "bfb41056a0e55e7b715c21ea9285cb1c" in i and "relevant_cell" not in i:
relevant_cell = i
if relevant_cell is None:
raise Exception("Did you run your custom code?")
with open(file_name, "w") as f:
f.write(relevant_cell)
def add_models_to_submission(model_regex):
import os
echo_and_run("git lfs install")
echo_and_run("git lfs track \"%s\"" % model_regex)
echo_and_run("git add .gitattributes")
def echo_and_run(command):
print("#> " + command)
return os.system(command)
def make_submission():
status_code = echo_and_run("ssh -o StrictHostKeyChecking=no -T git@gitlab.aicrowd.com")
if status_code > 1:
raise Exception("SSH login failed, did you add above SSH key in your account?")
!git push aicrowd master -f
!git push aicrowd --tags
def prepare_for_submission(class_name, commit_message=None):
import datetime
import time
timestamp_now = int(time.time())
time_now = datetime.datetime.utcnow().strftime('%B %d %Y - %H:%M:%S')
file_name = os.popen("grep -nr \"class %s\" *.py" % class_name).read().split(':')[0].split('.')[0]
predict_py_content = """#!/usr/bin/env python
from {file_name} import {class_name}
submission = {class_name}()
submission.run()
print("Successfully completed music demixing...")
""".format(class_name=class_name, file_name=file_name)
with open("predict.py", "w") as f:
f.write(predict_py_content)
echo_and_run("git add .")
if not commit_message:
commit_message = "Automated submission via notebook: %s" % time_now
if not AICROWD_USER_NAME or not AICROWD_EMAIL_ID:
raise Exception("AICROWD_USER_NAME or AICROWD_EMAIL_ID not configured")
echo_and_run("git config --global user.name \"%s\"" % AICROWD_USER_NAME)
echo_and_run("git config --global user.email \"%s\"" % AICROWD_EMAIL_ID)
echo_and_run("git commit -m \"%s\"" % commit_message)
echo_and_run("git remote add aicrowd git@gitlab.aicrowd.com:%s/music-demixing-challenge-starter-kit.git" % AICROWD_USER_NAME)
echo_and_run("git tag submission-v%s" % timestamp_now)
if not os.path.isfile("/root/.ssh/id_rsa.pub"):
echo_and_run('cat /dev/zero | ssh-keygen -q -N "" > /dev/null')
ssh_pub = open("/root/.ssh/id_rsa.pub").read()
return IPython.display.HTML("""
<h3>👉 Copy paste below ssh key to your profile:
<a href="https://gitlab.aicrowd.com/profile/keys" target="_blank">Add</a>
</h3>
<i>Please remove the SSH key from your profile after you make your submission.<i>
<br>
<textarea cols=100 rows=10>%s</textarea>""" % ssh_pub)
Configure your environment 📎¶
# Additional **pip** packages required by your submission
# Default list: https://github.com/AIcrowd/music-demixing-challenge-starter-kit/blob/master/requirements.txt
PIP_PACKAGES = [
'musdb',
]
# Additional **apt** packages required by your submission.
# Default list: https://github.com/AIcrowd/music-demixing-challenge-starter-kit/blob/master/apt.txt
APT_PACKAGES = [
'ffmpeg',
]
install_pip_and_apt_on_colab()
Download dataset files 💾¶
# You can select to download full dataset or 7s dataset, it will be present in `data/` folder.
# !python utility/verify_or_download_data.py
Baselines 🗃¶
Let's go through few of the baselines, before jumping to the problem!
🎶 Let's listen to example song added as part of starter kit.
import IPython, os
print("Original mixture:")
IPython.display.Audio("data/test/Mu - Too Bright/mixture.wav")
XUMXPredictor¶
This uses CrossNet-UMX (X-UMX) for music demixing.
!mkdir models && cd models && wget https://zenodo.org/record/4740378/files/pretrained_xumx_musdb18HQ.pth
from test_xumx import XUMXPredictor
xumx_predictor = XUMXPredictor()
xumx_predictor.evaluation()
xumx_predictor.scoring()
display_result("data/results/Mu - Too Bright")
openunmix¶
This uses openunmix for music demixing.
from test_umx import UMXPredictor
umx_predictor = UMXPredictor()
umx_predictor.evaluation()
umx_predictor.scoring()
display_result("data/results/Mu - Too Bright")
Your implementation here!! 🎉¶
You can write your own implementation in this cell OR use any of available baseline.
# Your training code
#!/usr/bin/env python
# This file is the entrypoint for your submission.
# You can modify this file to include your code or directly call your functions/modules from here.
#### Magic bfb41056a0e55e7b715c21ea9285cb1c: Do not remove it, it is used to detect your code in notebook.
import shutil
import soundfile as sf
from evaluator.music_demixing import MusicDemixingPredictor
class CustomPredictor(MusicDemixingPredictor):
def prediction_setup(self):
# Load your model here.
# self.separator = torch.hub.load('sigsep/open-unmix-pytorch', 'umxhq')
pass
"""
PARTICIPANT_TODO:
During the evaluation all music files will be provided one by one, along with destination path
for saving separated audios.
NOTE: In case you want to load your model, please do so in `predict_setup` function.
"""
def prediction(self, mixture_file_path, bass_file_path, drums_file_path, other_file_path, vocals_file_path):
# Write your prediction code here:
# [...]
# estimates = separator(audio)
# Save the wav files at assigned locations.
print("Mixture file is present at following location: %s" % mixture_file_path)
x, rate = sf.read(mixture_file_path) # mixture is stereo with sample rate of 44.1kHz
n_sources = 4
sf.write(bass_file_path, 1/n_sources * x, rate)
sf.write(drums_file_path, 1/n_sources * x, rate)
sf.write(other_file_path, 1/n_sources * x, rate)
sf.write(vocals_file_path, 1/n_sources * x, rate)
print("%s: prediction completed." % mixture_file_path)
if __name__ == "__main__":
submission = CustomPredictor()
submission.evaluation()
pprint.pprint(submission.scoring())
display_result("data/results/Mu - Too Bright")
# ENABLE BELOW FUNCTIONS IF YOU ARE DOING CUSTOM IMPLEMENTATION
#
write_custom_implementation("test.py")
add_models_to_submission("*.pt") #<- extension of files work, will be added via git-lfs
Ready? Submit to AIcrowd 🚀¶
If you are satisfied with your code, run the code below to send your code to the AIcrowd servers for evaluation!
Make sure you have included all packages needed to run your code in the "Packages" section.
!git tag -d $(git tag -l)
AICROWD_USER_NAME = 'shivam'
AICROWD_EMAIL_ID = 'shivam@aicrowd.com' # used for commit email, can be anything of your wish
# SUBMISSION_CLASS = "UMXPredictor"
# SUBMISSION_CLASS = "XUMXPredictor"
SUBMISSION_CLASS = "CustomPredictor"
prepare_for_submission(SUBMISSION_CLASS, commit_message="Meaningful description to my submission")
make_submission()
Content
Comments
You must login before you can post a comment.