GithubHelp home page GithubHelp logo

anticipation's Introduction

Anticipatory Music Transformer

Implementation of the methods described in Anticipatory Music Transformer.

by John Thickstun, David Hall, Chris Donahue, and Percy Liang.


This repository provides the code for creating anticipatory training datasets, and for sampling from models trained with anticipation. It does not contain code for training these models: you may use the preprocessed datasets constructed here as input to your favorite codebase for training autoregressive transformer models. We used the Levanter codebase to train models, and include instructions here for training an Anticipatory Music Transformer with Levanter.

For additional detail about this work, see the paper. You may also be interested in this blog post.

Pretrained models are hosted by the Center for Research on Foundation Models (CRFM) on the HuggingFace Hub.

This project is licensed under the terms of the Apache License, Version 2.0.

Begin by installing the anticipation package (from the root of this repository).

pip install .

Software Dependencies

Run the following command to install dependencies.

pip install -r requirements.txt

Generating Music with an Anticipatory Music Transformer

See the Colab notebook for interactive examples of music generation using the Anticipatory Music Transformer.

Load a pretrained model using the HuggingFace Transformers package, e.g.:

from transformers import AutoModelForCausalLM

model = AutoModelForCausalLM.from_pretrained('stanford-crfm/music-medium-800k').cuda()

Sample from this model using the custom generate function implementated by the anticipation package. You can convert generated event tokens to midi using the events_to_midi function:

from anticipation.sample import generate
from anticipation.convert import events_to_midi

length = 10 # time in seconds
events = generate(model, start_time=0, end_time=length, top_p=.98)
mid = events_to_midi(events)
mid.save('generated.mid')

Load your own MIDI and tokenize it using the midi_to_events function.

from anticipation.convert import midi_to_events

events = midi_to_events('examples/strawberry.mid')

To isolate a segment of a longer stream of events, use the ops library to clip the stream and translate the clipped segment to time zero. To isolate a melodic line, use extract_instruments:

from anticipation import ops
from anticipation.tokenize import extract_instruments

events = ops.clip(events, 41, 41+20)
events = ops.translate(events, -ops.min_time(events, seconds=False))

events, melody = extract_instruments(events, [53])

To generate an accompaniment to an isolated melody, call the generate function using the melody as control inputs. Recombine the generated accompaniment with the melody controls using ops.combine:

history = ops.clip(events, 0, 5, clip_duration=False)
accompaniment = generate(model, 5, 20, inputs=history, controls=melody, top_p=.98)
completed_events = ops.combine(accompaniment, melody)
mid = events_to_midi(completed_events)
mid.save('generated.mid')

See the Colab notebook for additional examples of infilling control using the Anticipatory Music Transformer.

Training an Anticipatory Music Transformer

See the train directory for instructions on preprocessing the Lakh MIDI dataset and using Levanter to train an Anticipatory Music Transformer.

Reproducing the Human Evaluation Procedure

See the humaneval directory for instructions on reproducing data used for the human evaluation results reported in the paper.


To reference this work, please cite

@article{thickstun2023anticipatory,
  title={Anticipatory Music Transformer},
  author={Thickstun, John and Hall, David and Donahue, Chris and Liang, Percy},
  journal={arXiv preprint arXiv:2306.08620},
  year={2023}
}

anticipation's People

Contributors

caenopy avatar jasminegonzalez10 avatar jthickstun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

anticipation's Issues

Finetuning Issue

Hi and thanks so much for sharing this great work.

I had it all set up following your guides from #14 and #7 but suddenly nothing seems to be working.

I did skipp this check as suggested and installed torch.

Now it throws:

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/levanter/src/levanter/main/train_lm.py", line 220, in <module>
    levanter.config.main(main)()
  File "/levanter/src/levanter/config.py", line 84, in wrapper_inner
    response = fn(cfg, *args, **kwargs)
  File "/levanter/src/levanter/main/train_lm.py", line 82, in main
    levanter.initialize(config)
  File "/levanter/src/levanter/trainer.py", line 796, in initialize
    trainer_config.initialize()
  File "/levanter/src/levanter/trainer.py", line 627, in initialize
    _initialize_global_tracker(self.tracker, id)
  File "/levanter/src/levanter/trainer.py", line 522, in _initialize_global_tracker
    tracker = config.init(run_id)
  File "/levanter/src/levanter/tracker/wandb.py", line 131, in init
    git_settings = self._git_settings()
  File "/levanter/src/levanter/tracker/wandb.py", line 204, in _git_settings
    sha = self._get_git_sha(code_dir)
  File "/levanter/src/levanter/tracker/wandb.py", line 216, in _get_git_sha
    git_sha = repo.head.commit.hexsha
  File "/usr/local/lib/python3.10/dist-packages/git/refs/symbolic.py", line 297, in _get_commit
    obj = self._get_object()
  File "/usr/local/lib/python3.10/dist-packages/git/refs/symbolic.py", line 288, in _get_object
    return Object.new_from_sha(self.repo, hex_to_bin(self.dereference_recursive(self.repo, self.path)))
  File "/usr/local/lib/python3.10/dist-packages/git/objects/base.py", line 149, in new_from_sha
    oinfo = repo.odb.info(sha1)
  File "/usr/local/lib/python3.10/dist-packages/git/db.py", line 41, in info
    hexsha, typename, size = self._git.get_object_header(bin_to_hex(binsha))
  File "/usr/local/lib/python3.10/dist-packages/git/cmd.py", line 1678, in get_object_header
    return self.__get_object_header(cmd, ref)
  File "/usr/local/lib/python3.10/dist-packages/git/cmd.py", line 1661, in __get_object_header
    cmd.stdin.flush()
BrokenPipeError: [Errno 32] Broken pipe

I am in contact with the Levander team but not sure how to approach since several things seem to have been updated both in JAX and in Lenater.

Any advice would be very much appreciated!

UnboundLocalError: local variable 'atime' referenced before assignment

Been using anticipation quite a lot in the last couple says and I have found that this error inevitably comes up while generating longer pieces (60-90 seconds)

UnboundLocalError Traceback (most recent call last)
in <cell line: 7>()
5 n = 10
6
----> 7 proposal = generate(model, start_time=length, end_time=length+n, inputs=history, top_p=0.98)
8 Audio(synthesize(fs, proposal))

/usr/local/lib/python3.10/dist-packages/anticipation/sample.py in generate(model, start_time, end_time, inputs, controls, top_p, debug, delta)
158 while True:
159 while current_time >= anticipated_time - delta:
--> 160 tokens.extend([atime, adur, anote])
161 if debug:
162 note = anote - ANOTE_OFFSET

UnboundLocalError: local variable 'atime' referenced before assignment

Fine-Tuning with Levanter + Anticipation: Environment Setup + safetensors vs pytorch_model.bin

Hello,

I created a new conda environment in wsl and proceeded to install levanter and anticipation from source. I was able to adapt and run the tokenization scripts for my needs and produced what seem to be non-empty tokenized files to use for fine-tuning.

However, when I install from requirements.txt after I install levanter, I get the following warning:
levanter 1.1 requires transformers>=4.32.0, but you have transformers 4.29.2 which is incompatible.

If I proceed with training anyway, I get the following error:

Traceback (most recent call last):
  File "/home/ian/miniconda3/envs/anticipation/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/ian/miniconda3/envs/anticipation/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/main/train_lm.py", line 194, in <module>
    levanter.config.main(main)()
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/config.py", line 83, in wrapper_inner
    cfg = parse(config_class=argtype, config_path=config_path, args=cmdline_args)
  File "/home/ian/miniconda3/envs/anticipation/lib/python3.10/site-packages/draccus/argparsing.py", line 186, in parse
    parser = ArgumentParser(
  File "/home/ian/miniconda3/envs/anticipation/lib/python3.10/site-packages/draccus/argparsing.py", line 73, in __init__
    self._set_dataclass(config_class)  # type: ignore
  File "/home/ian/miniconda3/envs/anticipation/lib/python3.10/site-packages/draccus/argparsing.py", line 87, in _set_dataclass
    new_wrapper.register_actions(parser=self.parser)
  File "/home/ian/miniconda3/envs/anticipation/lib/python3.10/site-packages/draccus/wrappers/dataclass_wrapper.py", line 64, in register_actions
    child.register_actions(parser)
  File "/home/ian/miniconda3/envs/anticipation/lib/python3.10/site-packages/draccus/wrappers/choice_wrapper.py", line 61, in register_actions
    children = self._children
  File "/home/ian/miniconda3/envs/anticipation/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/home/ian/miniconda3/envs/anticipation/lib/python3.10/site-packages/draccus/wrappers/choice_wrapper.py", line 97, in _children
    return {name: _wrap_child(child) for name, child in self.choice_type.get_known_choices().items()}
  File "/home/ian/miniconda3/envs/anticipation/lib/python3.10/site-packages/draccus/choice_types.py", line 190, in get_known_choices
    cls._discover_packages()
  File "/home/ian/miniconda3/envs/anticipation/lib/python3.10/site-packages/draccus/choice_types.py", line 209, in _discover_packages
    importlib.import_module(pkg_name)
  File "/home/ian/miniconda3/envs/anticipation/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/models/mistral.py", line 29, in <module>
    from transformers import MistralConfig as HfMistralConfig  # noqa: E402
ImportError: cannot import name 'MistralConfig' from 'transformers' (/home/ian/miniconda3/envs/anticipation/lib/python3.10/site-packages/transformers/__init__.py)

This seems to indicate MistralConfig is not in the transformers package 4.29.2, so I tried to update the transformers package to several future versions such as 4.34 and 4.35, but this began to create dependency conflicts between tokenizers, transformers and huggingface-hub, so I then just used the latest transformers 4.39, which seems to be OK dependancy wise between those 3 packages. When I then try training with python -m levanter.main.train_lm --config_path ./config/finetune.yaml I get the following error:

INFO:levanter.distributed:Not initializing jax.distributed because no distributed config was provided, and no cluster was detected.
INFO:jax._src.xla_bridge:Unable to initialize backend 'rocm': NOT_FOUND: Could not find registered platform with name: "rocm". Available platform names are: CUDA
INFO:jax._src.xla_bridge:Unable to initialize backend 'tpu': INTERNAL: Failed to open libtpu.so: libtpu.so: cannot open shared object file: No such file or directory
INFO:levanter.trainer:Setting run id to gjdk5n7w
2024-03-21T13:19:48 - 0 - levanter.tracker.wandb - wandb.py:200 - INFO :: Setting wandb code_dir to /mnt/c/Users/Ian/GitHub/levanter
wandb: Currently logged in as: ijb. Use `wandb login --relogin` to force relogin
wandb: Tracking run with wandb version 0.16.4
wandb: Run data is saved locally in /mnt/c/Users/Ian/GitHub/anticipation/wandb/run-20240321_131949-gjdk5n7w
wandb: Run `wandb offline` to turn off syncing.
wandb: Syncing run playful-universe-7
wandb: โญ๏ธ View project at https://wandb.ai/ijb/anticipation
wandb: ๐Ÿš€ View run at https://wandb.ai/ijb/anticipation/runs/gjdk5n7w
2024-03-21T13:19:52 - 0 - levanter.distributed - distributed.py:215 - INFO :: No auto-discovered ray address found. Using ray.init('local').
2024-03-21T13:19:52 - 0 - levanter.distributed - distributed.py:267 - INFO :: ray.init(address='local', namespace='levanter', **{})
/home/ian/miniconda3/envs/anticipation/lib/python3.10/subprocess.py:1796: RuntimeWarning: os.fork() was called. os.fork() is incompatible with multithreaded code, and JAX is multithreaded, so this will likely lead to a deadlock.
  self.pid = _posixsubprocess.fork_exec(
/home/ian/miniconda3/envs/anticipation/lib/python3.10/subprocess.py:1796: RuntimeWarning: os.fork() was called. os.fork() is incompatible with multithreaded code, and JAX is multithreaded, so this will likely lead to a deadlock.
  self.pid = _posixsubprocess.fork_exec(
2024-03-21 13:19:54,472 INFO worker.py:1715 -- Started a local Ray instance. View the dashboard at 127.0.0.1:8265
2024-03-21T13:19:55 - 0 - levanter.tracker.wandb - wandb.py:200 - INFO :: Setting wandb code_dir to /mnt/c/Users/Ian/GitHub/levanter
2024-03-21T13:19:55 - 0 - levanter.tracker.wandb - wandb.py:200 - INFO :: Setting wandb code_dir to /mnt/c/Users/Ian/GitHub/levanter
train:   0%|                                                                                   | 0/2001 [00:00<?, ?it/s]2024-03-21T13:19:56 - 0 - levanter.data.shard_cache - shard_cache.py:1575 - INFO :: Loading cache from /cache/validation
2024-03-21T13:19:56 - 0 - levanter.data.text - text.py:720 - INFO :: Building cache for validation...
[]
Traceback (most recent call last):
  File "/home/ian/miniconda3/envs/anticipation/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/ian/miniconda3/envs/anticipation/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/main/train_lm.py", line 194, in <module>
    levanter.config.main(main)()
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/config.py", line 84, in wrapper_inner
    response = fn(cfg, *args, **kwargs)
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/main/train_lm.py", line 105, in main
    eval_datasets = config.data.validation_sets(Pos.size)
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/data/text.py", line 675, in validation_sets
    validation_set = self.validation_set(seq_len, monitors)
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/data/text.py", line 670, in validation_set
    return self.token_seq_dataset("validation", seq_len, monitors)
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/data/text.py", line 699, in token_seq_dataset
    cache = self.build_or_load_cache(split, monitors=monitors)
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/data/text.py", line 730, in build_or_load_cache
    return TokenizedDocumentCache.build_or_load(
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/data/text.py", line 242, in build_or_load
    bt = BatchTokenizer(tokenizer, enforce_eos=enforce_eos, override_resources=override_resources)
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/data/text.py", line 356, in __init__
    should_append_eos = input_ids[-1] != tokenizer.eos_token_id and enforce_eos
IndexError: list index out of range
Traceback (most recent call last):
  File "/home/ian/miniconda3/envs/anticipation/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/ian/miniconda3/envs/anticipation/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/main/train_lm.py", line 194, in <module>
    levanter.config.main(main)()
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/config.py", line 84, in wrapper_inner
    response = fn(cfg, *args, **kwargs)
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/main/train_lm.py", line 105, in main
    eval_datasets = config.data.validation_sets(Pos.size)
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/data/text.py", line 675, in validation_sets
    validation_set = self.validation_set(seq_len, monitors)
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/data/text.py", line 670, in validation_set
    return self.token_seq_dataset("validation", seq_len, monitors)
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/data/text.py", line 699, in token_seq_dataset
    cache = self.build_or_load_cache(split, monitors=monitors)
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/data/text.py", line 730, in build_or_load_cache
    return TokenizedDocumentCache.build_or_load(
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/data/text.py", line 242, in build_or_load
    bt = BatchTokenizer(tokenizer, enforce_eos=enforce_eos, override_resources=override_resources)
  File "/mnt/c/Users/Ian/GitHub/levanter/src/levanter/data/text.py", line 356, in __init__
    should_append_eos = input_ids[-1] != tokenizer.eos_token_id and enforce_eos
IndexError: list index out of range

Lastly, I wanted to mention in your reply here #7 (comment)

That my code for your commenting out "hack" from the latest levanter main is a bit different than the one you linked to - not sure why. The lastest version seems to be here https://github.com/stanford-crfm/levanter/blob/43712f12bddf8e2827783b6276d8d5373563d866/src/levanter/main/train_lm.py#L63

Should I check out a past version of levanter? I wasn't exactly sure based on the instructions and dates you wrote it seems to be after the latest commit to levanter.

Anyway, my hunch is that it's related to the levanter version or transformers version incompatibility, but maybe something broke in the tokenization step? Here is my finetune.yaml also. Any thoughts appreciated:)

Doubt about Training

The effect of this model is amazing, I want to use my own data to train, but I am not proficient in jax. I encountered some bugs:
What is the version of levanter? I used the split_lakh branch, but I did not find the training entry, so I used the main branch, but encountered many problems.
What should be written in the tokenizer in the configuration file,
Should python src/levanter/main/train_lm.py --config_path be run to start training

Fine Tuning

Thank you very much for haring this work!!

Is there a way to fine tune autoregressive transformer models? I looked it up but couldn't find a method > my goal is to generate in a specific style on your trained model.

Questions about fine-tuning scripts

Thanks for sharing your work!!

I tried to fine-tune the script, and according to the information you provided in #7, the loss I get from running the fine-tuning model now seems to be starting from scratch, and it has been between 18.5~19.0.

Here's my run log.

(venv) PS C:\anticipation> python -m levanter.main.train_lm --config_path config/finetune.yaml
2024-01-08 22:10:00,051 INFO worker.py:1715 -- Started a local Ray instance. View the dashboard at 127.0.0.1:8265
wandb: Tracking run with wandb version 0.16.1
wandb: Run data is saved locally in C:\anticipation\wandb\run-20240108_221003-0lwockwz
wandb: Run wandb offline to turn off syncing.
wandb: Syncing run expert-lion-12
wandb: View project at https://wandb.ai/jci/anticipation
wandb: View run at https://wandb.ai/jci/anticipation/runs/0lwockwz
2024-01-08T22:10:11 - 0 - levanter.data.shard_cache - shard_cache.py:970 - INFO :: Loading cache from C:/training-data
/cache/validation
2024-01-08T22:10:11 - 0 - levanter.data.shard_cache - shard_cache.py:970 - INFO :: Loading cache from C:/training-data
/cache/train
2024-01-08T22:10:11 - 0 - levanter.checkpoint - checkpoint.py:368 - WARNING :: No checkpoints found in /checkpoints\0lwockwz
2024-01-08T22:10:12 - 0 - main - train_lm.py:124 - INFO :: No training checkpoint found. Initializing model from HF check
point 'stanford-crfm/music-medium-800k'
2024-01-08T22:10:16 - 0 - levanter.compat.hf_checkpoints - hf_checkpoints.py:503 - INFO :: Resizing model from 55028 to 50257
to match tokenizer vocab size
C:\anticipation\venv\lib\site-packages\jax_src\interpreters\mlir.py:627: UserWarning: Some donated buffers were not u
sable: ShapedArray(float32[55028,1024]).
See an explanation at https://jax.readthedocs.io/en/latest/faq.html#buffer-donation.
warnings.warn(f"Some donated buffers were not usable: {', '.join(unused_donations)}.\n{msg}")
train: 0%|โ–Ž Traceback (most recent call last): | 1/201 [05:36<18:40:59, 336.30s/it, loss=18.9]
eval: 647it [06:21, 1.53it/s, loss=19]
wandb: WARNING No program path found, not creating job artifact. See https://docs.wandb.ai/guides/launch/create-job
wandb: - 0.016 MB of 0.016 MB uploaded
wandb: Run history:
wandb: global_step โ–
wandb: learning_rate โ–
wandb: throughput/loading_time โ–
wandb: train/loss โ–
wandb:
wandb: Run summary:
wandb: backend gpu
wandb: global_step 0
wandb: learning_rate 0.0
wandb: num_devices 1
wandb: num_hosts 1
wandb: parameter_count 354823168
wandb: throughput/loading_time 2.04437
wandb: train/loss 18.89413

Some training environments

levanter ==1.1
jax jaxlib[GPU] == 0.4.12

Data operations are pre-prepared according to train ReadMe.md.
where interarrival-time data is preprocessed

python tokenize-lakh.py D:\Data\Dataset\lmd_full --augment 1 -i

My finetune.yaml

Conditional generation for an instrument

Thank you for sharing your work! Nice concept of 'anticipation'.

I wanted to experiment with generating notes, by choosing a specific instruments to generate notes for. However I couldn't find a way to do that. Is there a way to condition on a specfic instrument at any generation time?

For instance having an input of piano and drums, is it possible to generate specifically bass next to it that plays at the same time or after them?

vocab.json file in HF repos

Is there a reason there is no vocab.json file in the HF repos?

I tried digging for one and generating one with the model but no dice.

I'm asking as I've been exploring converting the model into ggml for potentially quicker inference but it seems like I need a vocab.json file

ValueError('channel must be in range

Here is an error that comes up intermittently. Usually with longer prompts.


KeyError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/anticipation/convert.py in compound_to_midi(tokens, debug)
223 try:
--> 224 track, previous_time, idx = track_idx[instrument]
225 except KeyError:

KeyError: 54

During handling of the above exception, another exception occurred:

ValueError Traceback (most recent call last)
7 frames
in <cell line: 8>()
6
7 proposal = generate(model, start_time=length, end_time=length+n, inputs=history, top_p=1.1)
----> 8 Audio(synthesize(fs, proposal))

in synthesize(fs, tokens)
10 # the MIDI synthesis script
11 def synthesize(fs, tokens):
---> 12 mid = events_to_midi(tokens)
13 mid.save('tmp.mid')
14 fs.midi_to_audio('tmp.mid', 'tmp.wav')

/usr/local/lib/python3.10/dist-packages/anticipation/convert.py in events_to_midi(tokens, debug)
337
338 def events_to_midi(tokens, debug=False):
--> 339 return compound_to_midi(events_to_compound(tokens, debug=debug), debug=debug)
340
341 def midi_to_events(midifile, debug=False):

/usr/local/lib/python3.10/dist-packages/anticipation/convert.py in compound_to_midi(tokens, debug)
232 message = mido.Message('program_change', channel=idx, program=0)
233 else:
--> 234 message = mido.Message('program_change', channel=idx, program=instrument)
235 track.append(message)
236 num_tracks += 1

/usr/local/lib/python3.10/dist-packages/mido/messages/messages.py in init(self, type, **args)
112 if type == 'sysex':
113 msgdict['data'] = SysexData(convert_py2_bytes(msgdict['data']))
--> 114 check_msgdict(msgdict)
115 vars(self).update(msgdict)
116

/usr/local/lib/python3.10/dist-packages/mido/messages/checks.py in check_msgdict(msgdict)
97 '{} message has no attribute {}'.format(spec['type'], name))
98
---> 99 check_value(name, value)

/usr/local/lib/python3.10/dist-packages/mido/messages/checks.py in check_value(name, value)
84
85 def check_value(name, value):
---> 86 _CHECKSname
87
88

/usr/local/lib/python3.10/dist-packages/mido/messages/checks.py in check_channel(channel)
14 raise TypeError('channel must be int')
15 elif not 0 <= channel <= 15:
---> 16 raise ValueError('channel must be in range 0..15')
17
18

ValueError: channel must be in range 0..15

Thank you for sharing your work!

Hi guys,

Thank you for sharing your work and thank you for the samples/demo colab :) It was a clever idea to use the seq2seq approach for infilling and the samples sound great :)

On your site, you asked to reach out if interested in collabing, so here I am :)

First of all, I wanted to report some minor issues and make some suggestions...

  1. Your FluidSynth rendering implementation produces choppy output. The output MIDI comes out fine but the audio render is choppy. See attachments.

  2. Your demo model struggles with infilling Piano performances. This is probably because you used the LAKH dataset which is mostly multi-instrumental music. So my suggestion for the future is to dilute LAKH with some Piano datasets. I use ASAP+ATEPP+GiantMIDI with good results. See attachments.

  3. Reducing the number of instruments to the most common ones helps the model to perform. Full MIDI range (127) is usually too much and has very little utility. I personally use 10 to 12 most common ones in my implementations and it helps to improve performance and model accuracy/loss.

  4. You might want to think about adding partial velocity to your model/implementation. I use octo-velocity (128/16=8 steps) with good results without any noticeable performance degradation.

I hope any of this will be useful for you to improve your work and I hope it is not too much for an unsolicited commentary :)

Now, I also wanted to invite you to check out my similar inpainting-related project/models because I think it may give you some ideas and I think it may also help you to improve your work.

https://github.com/asigalov61/Euterpe-X

Inpaiting/nfilling and continutation/harmonization demo is located in this colab:

https://colab.research.google.com/github/asigalov61/Euterpe-X/blob/main/Euterpe_X.ipynb

But there are other features in other provided colabs that you might want to check out.

Last but not least, I have some questions for you:

  1. What method(s) do you use for accompaniment generation? Is it simple infilling or do you use a combination of masking and infilling? I am still trying to figure out how to make naturally sounding accompaniment for my models and I would be interested in learning from you because your samples sound very good.

  2. Would you (and Stanford in particular) be willing to colab on and make for this project a public API and public interface ala OpenAI's MuseNet? After OpenAI depreciated the MuseNet project there are no publicly available symbolic music models that could be used to compose music, so it would be nice if we could fill this gap. I know that the main issue is developing the API/interface and an even more difficult issue is the compute resources, but maybe with the help of Stanford, we would be able to do it somehow.

This is all for now and I hope to hear your response.

Most sincerely,

Alex.

eval_samples.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.