MidiTok version and code corrections

#1
by asigalov61 - opened

Hey @Natooz

I am posting it here so that you can correct it...

Please update the recommended MidiTok version to the latest one because 2.7.1 does not work. The latest version (3.0.4) seems to work fine.

Also, please update the code snippet for both models. This is what worked for me:

import torch
from transformers import AutoModelForCausalLM
from miditok import TSD
from symusic import Score

torch.set_default_device("cuda")
model = AutoModelForCausalLM.from_pretrained("Natooz/Maestro-TSD-bpe20k", trust_remote_code=True, torch_dtype="auto")
tokenizer = TSD.from_pretrained("Natooz/Maestro-TSD-bpe20k")
input_midi = Score("Giant-Music-Transformer-Piano-Seed-1.mid")
input_tokens = tokenizer(input_midi)

generated_token_ids = model.generate(torch.LongTensor([input_tokens[0].ids]).cuda(), max_length=500)
generated_midi = tokenizer(generated_token_ids.tolist())
generated_midi.dump_midi("continued.mid")

Hope this is helpful :)

Alex

Sign up or log in to comment