Supplementary code for the experiments described in the 2021 ISMIR submission: Leveraging Hierarchical Structures for Few Shot Musical Instrument Recognition.
- For all experiments, we used the instrument-based split in
/music_trees/assets/partitions/mdb-aug.json
. - To view our Hornbostel-Sachs class hierarchy, see
/music_trees/assets/taxonomies/deeper-mdb.yaml
. Note that not all of the instruments on this taxonomy are used in our experiments. - All random taxonomies are in
/music_trees/assets/taxonomies/scrambled-*.yaml
first, clone the medleydb repo and install using pip install -e
:
- medleydb from marl
Now, download the medleydb and mdb 2.0 datasets from zenodo.
install some utilities for visualizing the embedding space:
git clone https://github.com/hugofloresgarcia/embviz.git
cd embviz
pip install -e .
then, clone this repo and install with
pip install -e .
Make sure the MEDLEYDB_PATH
environment variable is set (see the medleydb repo for more instructions ). Then, run the
generation script:
python -m music_trees.generate \
--dataset mdb \
--name mdb-aug \
--example_length 1.0 \
--augment true \
--hop_length 0.5 \
--sample_rate 16000 \
This will generate both augmented and unaugmented data for MedleyDB. NOTE: There was a bug in the code that disabled data augmentation silently. This bug has been left in the code for the sake of reproducibility. This is why we don't report any data augmentation in the paper, as none was applied at the time of experiments.
The partition file used for all experiments is available at /music_trees/assets/partitions/mdb-aug.json
.
The search
script will train all models for a particular experiment. It will grab as many GPUs are available (use CUDA_VISIBLE_DEVICES
to change the availability of GPUs) and train as many models as it can in parallel.
Each model will be stored under /runs/<NAME>/<VERSION>
.
Arbitrary Hierarchies
python music_trees/search.py --name scrambled-tax
Height Search
(note that height=0
and height=1
are the baseline and proposed model, respectively)
python music_trees/search.py --name height-v1
Loss Ablation
python music_trees/search.py --name loss-alpha
train the additional BCE baseline:
python music_trees/train.py --model_name hprotonet --height 4 --d_root 128 --loss_alpha 1 --name "flat (BCE)" --dataset mdb-aug --learning_rate 0.03 --loss_weight_fn cross-entropy
Perform evaluation on a model. Make sure to pass the path to the run that you wish to evaluate.
To evaluate a model:
python music_trees/eval.py --exp_dir <PATH_TO_RUN>/<VERSION>
Each model will store its evaluation results under /results/<NAME>/<VERSION>
To compare models and generate analysis figures and tables, place of all the results folders you would like to analyze under a single folder. The resulting folder should look like this:
my_experiment/trial1/version_0
my_experiment/trial2/version_0
my_experiment/trial3/version_0
Then, run analysis using
python music_trees analyze.py my_experiment <OUTPUT_NAME>
the figures will be created under /analysis/<OUTPUT_NAME>
To generate paper-ready figures, see scripts/figures.ipynb
.