https://github.com/amazon-science/transformer-gan

https://github.com/amazon-science/transformer-gan

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.2%) to scientific vocabulary
Last synced: 11 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: amazon-science
  • License: apache-2.0
  • Language: Python
  • Default Branch: main
  • Size: 115 KB
Statistics
  • Stars: 50
  • Watchers: 1
  • Forks: 12
  • Open Issues: 4
  • Releases: 0
Created over 5 years ago · Last pushed about 5 years ago
Metadata Files
Readme Contributing License Code of conduct

README.md

Symbolic Music Generation with Transformer-GANs

Code for the paper "Symbolic Music Generation with Transformer-GANs" (AAAI 2021)

If you use this code, please cite the paper using the bibtex reference below. @inproceedings{transformer-gan, title={Symbolic Music Generation with Transformer-GANs}, author={Aashiq Muhamed and Liang Li and Xingjian Shi and Suri Yaddanapudi and Wayne Chi and Dylan Jackson and Rahul Suresh and Zachary C. Lipton and Alexander J. Smola}, booktitle={35th AAAI Conference on Artificial Intelligence, {AAAI} 2021}, year={2021}, }

Requirements

  • Python 3.6+
  • Pytorch
  • Transformers

You can install all required Python packages with bash requirements.sh.

Datasets, switching inside data folder

  • Downloaded data

bash bash get_data.sh

  • Run music_encoder.py to generate the encoded numpy files
    • Messages stating that pitches are out of range are expected behavior

bash python3 music_encoder.py --encode_official_maestro \ --mode midi_to_npy \ --pitch_transpose_lower -3 \ --pitch_transpose_upper 3 \ --output_folder ./maestro_magenta_s5_t3

Train and Generate: switching inside model folder

  • Train a Transformer XL (No GAN)

bash python3 -m torch.distributed.launch --nproc_per_node=4 ./train.py \ --data_dir ../data/maestro_magenta_s5_t3 \ --cfg ./training_config/experiment_baseline.yml \ --work_dir exp_dir

  • Train a Transformer XL (with GAN)

bash python3 -m torch.distributed.launch --nproc_per_node=4 ./train.py \ --data_dir ../data/maestro_magenta_s5_t3 \ --cfg ./training_config/experiment_spanbert.yml \ --work_dir exp_dir

  • Generate unconditional samples

```

generate unconditional samples

python3 generate.py --inferenceconfig inferenceconfig/inference_unconditional.yml ```

Note, if you are loading an old config.yml file which includes None/" " inside, please change it to a string 'Null' to make sure you can do cfg.mergefromfile.

  • Extend music to generate conditional samples

```

generate conditional samples

python3 generate.py --inferenceconfig inferenceconfig/inference_conditional.yml

```

  1. Please set conditionlen as well as conditionfile
  2. Change memlen and genlen. memlen=genlen is recommended

Post process for data (convert .txt to .mid)

  • Run the following to get midi files from txt files
    • Use --mode to_midi for text file conversions. Use --mode npy_to_midi for numpy file conversions.

bash python3 ../data/music_encoder.py --input_folder ./Output_Uncondtitionl --output_folder ./Output_Uncondtitionl_MIDI --mode to_midi python3 ../data/music_encoder.py --input_folder ./Output_Condtitionl --output_folder ./Output_Condtitionl_MIDI --mode to_midi

different methods inside music_encoder

  • encoder.to_text(input.mid, output.txt)
  • encoder.from_text(input.txt, out.mid)
  • encoder.encode_vocab(input.mid) return list of ids
  • encoder.decoder_vocab(list(ids)) return out.mid
  • encoder.totextargumentaion(input.mid, output.txt)

Owner

  • Name: Amazon Science
  • Login: amazon-science
  • Kind: organization

GitHub Events

Total
  • Issue comment event: 1
  • Fork event: 1
Last Year
  • Issue comment event: 1
  • Fork event: 1

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 2
  • Total Committers: 2
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.5
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Amazon GitHub Automation 5****o 1
mzliang-annie m****g@a****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: about 1 year ago

All Time
  • Total issues: 9
  • Total pull requests: 0
  • Average time to close issues: 1 day
  • Average time to close pull requests: N/A
  • Total issue authors: 5
  • Total pull request authors: 0
  • Average comments per issue: 1.11
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • zzingae (2)
  • hyeshinchu (1)
  • li-car-fei (1)
  • L-XM (1)
  • wzk1015 (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels