{"id":13711768,"url":"https://github.com/salu133445/musegan","last_synced_at":"2025-05-15T08:09:24.108Z","repository":{"id":37617408,"uuid":"103350832","full_name":"salu133445/musegan","owner":"salu133445","description":"An AI for Music Generation","archived":false,"fork":false,"pushed_at":"2024-06-07T10:22:36.000Z","size":75263,"stargazers_count":1922,"open_issues_count":21,"forks_count":383,"subscribers_count":49,"default_branch":"main","last_synced_at":"2025-04-14T12:18:21.162Z","etag":null,"topics":["gan","generative-adversarial-network","machine-learning","music","music-generation","tensorflow"],"latest_commit_sha":null,"homepage":"https://salu133445.github.io/musegan/","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,"zenodo":null},"funding":{"github":"salu133445"}},"created_at":"2017-09-13T03:52:31.000Z","updated_at":"2025-04-08T13:03:46.000Z","dependencies_parsed_at":"2024-06-07T11:39:15.737Z","dependency_job_id":null,"html_url":"https://github.com/salu133445/musegan","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salu133445%2Fmusegan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salu133445%2Fmusegan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salu133445%2Fmusegan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salu133445%2Fmusegan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/salu133445","download_url":"https://codeload.github.com/salu133445/musegan/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248877968,"owners_count":21176244,"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":["gan","generative-adversarial-network","machine-learning","music","music-generation","tensorflow"],"created_at":"2024-08-02T23:01:11.422Z","updated_at":"2025-04-14T12:18:38.968Z","avatar_url":"https://github.com/salu133445.png","language":"Python","funding_links":["https://github.com/sponsors/salu133445"],"categories":["Python","Natural Language Processing","GitHub projects"],"sub_categories":["Speech \u0026 Audio"],"readme":"# MuseGAN\n\n[MuseGAN](https://salu133445.github.io/musegan/) is a project on music\ngeneration. In a nutshell, we aim to generate polyphonic music of multiple\ntracks (instruments). The proposed models are able to generate music either from\nscratch, or by accompanying a track given a priori by the user.\n\nWe train the model with training data collected from\n[Lakh Pianoroll Dataset](https://salu133445.github.io/lakh-pianoroll-dataset/)\nto generate pop song phrases consisting of bass, drums, guitar, piano and\nstrings tracks.\n\nSample results are available\n[here](https://salu133445.github.io/musegan/results).\n\n## Important Notes\n\n- The latest implementation is based on the network architectures presented in BinaryMuseGAN, where the temporal structure is handled by 3D convolutional layers. The advantage of this design is its smaller network size, while the disadvantage is its reduced controllability, e.g., capability of feeding different latent variables for different measures or tracks.\n- The original code we used for running the experiments in the paper can be found in the `v1` folder.\n- Looking for a PyTorch version? Check out [this repository](https://github.com/salu133445/ismir2019tutorial).\n\n## Prerequisites\n\n\u003e __Below we assume the working directory is the repository root.__\n\n### Install dependencies\n\n- Using pipenv (recommended)\n\n  \u003e Make sure `pipenv` is installed. (If not, simply run `pip install pipenv`.)\n\n  ```sh\n  # Install the dependencies\n  pipenv install\n  # Activate the virtual environment\n  pipenv shell\n  ```\n\n- Using pip\n\n  ```sh\n  # Install the dependencies\n  pip install -r requirements.txt\n  ```\n\n### Prepare training data\n\n\u003e The training data is collected from\n[Lakh Pianoroll Dataset](https://salu133445.github.io/lakh-pianoroll-dataset/)\n(LPD), a new multitrack pianoroll dataset.\n\n```sh\n# Download the training data\n./scripts/download_data.sh\n# Store the training data to shared memory\n./scripts/process_data.sh\n```\n\nYou can also download the training data manually\n([train_x_lpd_5_phr.npz](https://ucsdcloud-my.sharepoint.com/:u:/g/personal/h3dong_ucsd_edu/EZLHzG70AUlLrq3dOPLno3YBORq8ISaJf4UOCbdnKS_CgA?e=fxDPVK)).\n\n\u003e As pianoroll matrices are generally sparse, we store only the indices of\nnonzero elements and the array shape into a npz file to save space, and later\nrestore the original array. To save some training data `data` into this format,\nsimply run\n`np.savez_compressed(\"data.npz\", shape=data.shape, nonzero=data.nonzero())`\n\n## Scripts\n\nWe provide several shell scripts for easy managing the experiments. (See\n[here](scripts/README.md) for a detailed documentation.)\n\n\u003e __Below we assume the working directory is the repository root.__\n\n### Train a new model\n\n1. Run the following command to set up a new experiment with default settings.\n\n   ```sh\n   # Set up a new experiment\n   ./scripts/setup_exp.sh \"./exp/my_experiment/\" \"Some notes on my experiment\"\n   ```\n\n2. Modify the configuration and model parameter files for experimental settings.\n\n3. You can either train the model:\n\n     ```sh\n     # Train the model\n     ./scripts/run_train.sh \"./exp/my_experiment/\" \"0\"\n     ```\n\n   or run the experiment (training + inference + interpolation):\n\n     ```sh\n     # Run the experiment\n     ./scripts/run_exp.sh \"./exp/my_experiment/\" \"0\"\n     ```\n\n### Collect training data\n\nRun the following command to collect training data from MIDI files.\n\n  ```sh\n  # Collect training data\n  ./scripts/collect_data.sh \"./midi_dir/\" \"data/train.npy\"\n  ```\n\n### Use pretrained models\n\n1. Download pretrained models\n\n   ```sh\n   # Download the pretrained models\n   ./scripts/download_models.sh\n   ```\n\n   You can also download the pretrained models manually\n   ([pretrained_models.tar.gz](https://ucsdcloud-my.sharepoint.com/:u:/g/personal/h3dong_ucsd_edu/Ea2kDl2YokNIiZ_OXxzgclYBX0Tk-awE2kDlm2HO9ofqPg)).\n\n2. You can either perform inference from a trained model:\n\n   ```sh\n   # Run inference from a pretrained model\n   ./scripts/run_inference.sh \"./exp/default/\" \"0\"\n   ```\n\n   or perform interpolation from a trained model:\n\n   ```sh\n   # Run interpolation from a pretrained model\n   ./scripts/run_interpolation.sh \"./exp/default/\" \"0\"\n   ```\n\n## Outputs\n\nBy default, samples will be generated alongside the training. You can disable\nthis behavior by setting `save_samples_steps` to zero in the configuration file\n(`config.yaml`). The generated will be stored in the following three formats by\ndefault.\n\n- `.npy`: raw numpy arrays\n- `.png`: image files\n- `.npz`: multitrack pianoroll files that can be loaded by the\n  _[Pypianoroll](https://salu133445.github.io/pypianoroll/index.html)_\n  package\n\nYou can disable saving in a specific format by setting `save_array_samples`,\n`save_image_samples` and `save_pianoroll_samples` to `False`  in the\nconfiguration file.\n\nThe generated pianorolls are stored in .npz format to save space and processing\ntime. You can use the following code to write them into MIDI files.\n\n```python\nfrom pypianoroll import Multitrack\n\nm = Multitrack('./test.npz')\nm.write('./test.mid')\n```\n\n## Sample Results\n\nSome sample results can be found in `./exp/` directory. More samples can be\ndownloaded from the following links.\n\n- [`sample_results.tar.gz`](https://ucsdcloud-my.sharepoint.com/:u:/g/personal/h3dong_ucsd_edu/EedDKNyGHshHkIwBk_QghdYBrrzg-KOQFnj6zGLW3o-sOQ?e=ixlAwG) (54.7 MB):\n  sample inference and interpolation results\n- [`training_samples.tar.gz`](https://ucsdcloud-my.sharepoint.com/:u:/g/personal/h3dong_ucsd_edu/ES96MN0l3xZLvJ3FW7TbV7IBFsFQY-IZhgf9IbRNyR9RIA?e=GpQv4o) (18.7 MB):\n  sample generated results at different steps\n\nCiting\n------\n\nPlease cite the following paper if you use the code provided in this repository.\n\nHao-Wen Dong\\*, Wen-Yi Hsiao\\*, Li-Chia Yang and Yi-Hsuan Yang, \"MuseGAN: Multi-track Sequential Generative Adversarial Networks for Symbolic\nMusic Generation and Accompaniment,\" _AAAI Conference on Artificial Intelligence (AAAI)_, 2018. (\\*equal contribution)\n\u003cbr\u003e\n[[homepage](https://salu133445.github.io/musegan)]\n[[arXiv](http://arxiv.org/abs/1709.06298)]\n[[paper](https://salu133445.github.io/musegan/pdf/musegan-aaai2018-paper.pdf)]\n[[slides](https://salu133445.github.io/musegan/pdf/musegan-aaai2018-slides.pdf)]\n[[code](https://github.com/salu133445/musegan)]\n\n## Papers\n\n__MuseGAN: Multi-track Sequential Generative Adversarial Networks for Symbolic Music Generation and Accompaniment__\u003cbr\u003e\nHao-Wen Dong\\*, Wen-Yi Hsiao\\*, Li-Chia Yang and Yi-Hsuan Yang (\\*equal contribution)\u003cbr\u003e\n_AAAI Conference on Artificial Intelligence (AAAI)_, 2018.\u003cbr\u003e\n[[homepage](https://salu133445.github.io/musegan)]\n[[arXiv](http://arxiv.org/abs/1709.06298)]\n[[paper](https://salu133445.github.io/musegan/pdf/musegan-aaai2018-paper.pdf)]\n[[slides](https://salu133445.github.io/musegan/pdf/musegan-aaai2018-slides.pdf)]\n[[code](https://github.com/salu133445/musegan)]\n\n__Convolutional Generative Adversarial Networks with Binary Neurons for Polyphonic Music Generation__\u003cbr\u003e\nHao-Wen Dong and Yi-Hsuan Yang\u003cbr\u003e\n_International Society for Music Information Retrieval Conference (ISMIR)_, 2018.\u003cbr\u003e\n[[homepage](https://salu133445.github.io/bmusegan)]\n[[video](https://youtu.be/r9C2Q2oR9Ik)]\n[[paper](https://salu133445.github.io/bmusegan/pdf/bmusegan-ismir2018-paper.pdf)]\n[[slides](https://salu133445.github.io/bmusegan/pdf/bmusegan-ismir2018-slides.pdf)]\n[[slides (long)](https://salu133445.github.io/bmusegan/pdf/bmusegan-tmac2018-slides.pdf)]\n[[poster](https://salu133445.github.io/bmusegan/pdf/bmusegan-ismir2018-poster.pdf)]\n[[arXiv](https://arxiv.org/abs/1804.09399)]\n[[code](https://github.com/salu133445/bmusegan)]\n\n__MuseGAN: Demonstration of a Convolutional GAN Based Model for Generating Multi-track Piano-rolls__\u003cbr\u003e\nHao-Wen Dong\\*, Wen-Yi Hsiao\\*, Li-Chia Yang and Yi-Hsuan Yang (\\*equal contribution)\u003cbr\u003e\n_ISMIR Late-Breaking Demos_, 2017.\u003cbr\u003e\n[[paper](https://salu133445.github.io/musegan/pdf/musegan-ismir2017-lbd-paper.pdf)]\n[[poster](https://salu133445.github.io/musegan/pdf/musegan-ismir2017-lbd-poster.pdf)]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalu133445%2Fmusegan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsalu133445%2Fmusegan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalu133445%2Fmusegan/lists"}