{"id":13862009,"url":"https://github.com/salu133445/arranger","last_synced_at":"2025-03-25T20:32:00.295Z","repository":{"id":47386534,"uuid":"329496882","full_name":"salu133445/arranger","owner":"salu133445","description":"Official Implementation of \"Towards Automatic Instrumentation by Learning to Separate Parts in Symbolic Multitrack Music\" (ISMIR 2021)","archived":false,"fork":false,"pushed_at":"2023-06-26T07:40:36.000Z","size":202668,"stargazers_count":58,"open_issues_count":1,"forks_count":8,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-19T03:33:46.719Z","etag":null,"topics":["machine-learning","music","music-information-retrieval","tensorflow"],"latest_commit_sha":null,"homepage":"https://salu133445.github.io/arranger/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/salu133445.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"salu133445"}},"created_at":"2021-01-14T03:28:25.000Z","updated_at":"2025-01-01T11:14:38.000Z","dependencies_parsed_at":"2024-08-05T06:14:34.909Z","dependency_job_id":null,"html_url":"https://github.com/salu133445/arranger","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salu133445%2Farranger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salu133445%2Farranger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salu133445%2Farranger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salu133445%2Farranger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/salu133445","download_url":"https://codeload.github.com/salu133445/arranger/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245540345,"owners_count":20632144,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["machine-learning","music","music-information-retrieval","tensorflow"],"created_at":"2024-08-05T06:01:34.777Z","updated_at":"2025-03-25T20:31:59.471Z","avatar_url":"https://github.com/salu133445.png","language":"Python","funding_links":["https://github.com/sponsors/salu133445"],"categories":["Python"],"sub_categories":[],"readme":"# Arranger\n\nThis repository contains the official implementation of \"Towards Automatic Instrumentation by Learning to Separate Parts in Symbolic Multitrack Music\" (ISMIR 2021).\n\n__Towards Automatic Instrumentation by Learning to Separate Parts in Symbolic Multitrack Music__\u003cbr\u003e\nHao-Wen Dong, Chris Donahue, Taylor Berg-Kirkpatrick and Julian McAuley\u003cbr\u003e\n_Proceedings of the International Society for Music Information Retrieval Conference (ISMIR)_, 2021\u003cbr\u003e\n[[homepage](https://salu133445.github.io/arranger/)]\n[[paper](https://arxiv.org/pdf/2107.05916.pdf)]\n[[video](https://youtu.be/-KncOGouAh8)]\n[[slides](https://salu133445.github.io/arranger/pdf/arranger-ismir2021-slides.pdf)]\n[[video (long)](https://youtu.be/RMhzOuHJ5UI)]\n[[slides (long)](https://salu133445.github.io/arranger/pdf/arranger-research-exam-slides.pdf)]\n[[code](https://github.com/salu133445/arranger)]\n\n## Content\n\n- [Content](#content)\n- [Prerequisites](#prerequisites)\n- [Directory structure](#directory-structure)\n- [Data Collection](#data-collection)\n- [Data Preprocessing](#data-preprocessing)\n- [Models](#models)\n- [Baseline algorithms](#baseline-algorithms)\n- [Configuration](#configuration)\n- [Citation](#citation)\n\n\n## Prerequisites\n\nYou can install the dependencies by running `pipenv install` (recommended) or `python3 setup.py install -e .`. Python\u003e3.6 is required.\n\n## Directory structure\n\n```text\n├─ analysis         Notebooks for analysis\n├─ scripts          Scripts for running experiments\n├─ models           Pretrained models\n└─ arranger         Main Python module\n   ├─ config.yaml   Configuration file\n   ├─ data          Code for collecting and processing data\n   ├─ common        Most-common algorithm\n   ├─ zone          Zone-based algorithm\n   ├─ closest       Closest-pitch algorithm\n   ├─ lstm          LSTM model\n   └─ transformer   Transformer model\n```\n\n## Data Collection\n\n### Bach Chorales\n\n```python\n# Collect Bach chorales from the music21 corpus\nimport shutil\nimport music21.corpus\n\nfor path in music21.corpus.getComposer(\"bach\"):\n    if path.suffix in (\".mxl\", \".xml\"):\n        shutil.copyfile(path, \"data/bach/raw/\" + path.name)\n```\n\n### MusicNet\n\n```sh\n# Download the metadata\nwget -O data/musicnet https://homes.cs.washington.edu/~thickstn/media/musicnet_metadata.csv\n```\n\n### NES Music Database\n\n```sh\n# Download the dataset\nwget -O data/nes http://deepyeti.ucsd.edu/cdonahue/nesmdb/nesmdb_midi.tar.gz\n\n# Extract the archive\ntar zxf data/nes/nesmdb_midi.tar.gz\n\n# Rename the folder for consistency\nmv nesmdb_midi/ raw/\n```\n\n### Lakh MIDI Dataset (LMD)\n\n```sh\n# Download the dataset\nwget -O data/lmd http://hog.ee.columbia.edu/craffel/lmd/lmd_matched.tar.gz\n\n# Extract the archive\ntar zxf data/lmd/lmd_matched.tar.gz\n\n# Rename the folder for consistency\nmv lmd_matched/ raw/\n\n# Download the filenames\nwget -O data/lmd http://hog.ee.columbia.edu/craffel/lmd/md5_to_paths.json\n```\n\n## Data Preprocessing\n\n\u003e The following commands assume Bach chorales. You might want to replace the dataset identifier `bach` with identifiers of other datasets (`musicnet` for MusicNet, `nes` for NES Music Database and `lmd` for Lakh MIDI Dataset).\n\n```sh\n# Preprocess the data\npython3 arranger/data/collect_bach.py -i data/bach/raw/ -o data/bach/json/ -j 1\n\n# Collect training data\npython3 arranger/data/collect.py -i data/bach/json/ -o data/bach/s_500_m_10/ -d bach -s 500 -m 10 -j 1\n```\n\n## Models\n\n- LSTM model\n  - `arranger/lstm/train.py`: Train the LSTM model\n  - `arranger/lstm/infer.py`: Infer with the LSTM model\n- Transformer model\n  - `arranger/transformer/train.py`: Train the Transformer model\n  - `arranger/transformer/infer.py`: Infer with the Transformer model\n\n## Pretrained Models\n\nPretrained models can be found in the `models/` directory.\n\nTo run a pretrained model, please pass the corresponding command line options to the `infer.py` scripts. You may want to follow the commands used in the experiment scripts provided in `scripts/infer_*.sh`.\n\nFor example, use the following command to run the pretrained BiLSTM model with embeddings.\n\n```sh\n# Assuming we are at the root of the repository\ncp models/bach/lstm/bidirectional_embedding/best_models.hdf5 OUTPUT_DIRECTORY\npython3 arranger/lstm/infer.py \\\n  -i {INPUT_DIRECTORY} -o {OUTPUT_DIRECTORY} \\\n  -d bach -g 0 -bi -pe -bp -be -fi\n```\n\nThe input directory (`INPUT_DIRECTORY`) contains the input JSON files, which can be generated by `muspy.save()`. The output directory (`OUTPUT_DIRECTORY`) should contain the pretrained model and will contain the output files. The `-d bach` option indicates that we are using the Bach chorale dataset. The `-g 0` option will run the model on the first GPU. The `-bi -pe -bp -be -fi` specifies the model options (run `python3 arranger/lstm/infer.py -h` for more information).\n\n## Baseline algorithms\n\n- Most-common algorithm\n  - `arranger/common/learn.py`: Learn the most common label\n  - `arranger/common/infer.py`: Infer with the most-common algorithm\n- Zone-based algorithm\n  - `arranger/zone/learn.py`: Learn the optimal zone setting\n  - `arranger/zone/infer.py`: Infer with the zone-based algorithm\n- Closest-pitch algorithm\n  - `arranger/closest/infer.py`: Infer with the closest-pitch algorithm\n- MLP model\n  - `arranger/mlp/train.py`: Train the MLP model\n  - `arranger/mlp/infer.py`: Infer with the MLP model\n\n## Configuration\n\nIn `arranger/config.yaml`, you can configure the MIDI program numbers used for each track in the sample files generated. You can also configure the color of the generated sample piano roll visualization.\n\n## Citation\n\nPlease cite the following paper if you use the code provided in this repository.\n\n\u003e Hao-Wen Dong, Chris Donahue, Taylor Berg-Kirkpatrick and Julian McAuley, \"Towards Automatic Instrumentation by Learning to Separate Parts in Symbolic Multitrack Music,\" _Proceedings of the International Society for Music Information Retrieval Conference (ISMIR)_, 2021.\n\n```bibtex\n@inproceedings{dong2021arranger,\n    author = {Hao-Wen Dong and Chris Donahue and Taylor Berg-Kirkpatrick and Julian McAuley},\n    title = {Towards Automatic Instrumentation by Learning to Separate Parts in Symbolic Multitrack Music},\n    booktitle = {Proceedings of the International Society for Music Information Retrieval Conference (ISMIR)},\n    year = 2021,\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalu133445%2Farranger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsalu133445%2Farranger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalu133445%2Farranger/lists"}