GithubHelp home page GithubHelp logo

bearpelican / musicautobot Goto Github PK

View Code? Open in Web Editor NEW
519.0 15.0 106.0 84.86 MB

Using deep learning to generate music in MIDI format.

License: MIT License

Jupyter Notebook 92.71% Python 7.27% Shell 0.03%

musicautobot's Introduction

MusicAutobot

Using Deep Learning to generate pop music!

You can also experiment through the web app - musicautobot.com

Screenshot

Overview

Recent advances in NLP have produced amazing results in generating text. Transformer architecture is a big reason behind this.

This project aims to leverage these powerful language models and apply them to music. It's built on top of the fast.ai library

Implementation

MusicTransformer - This basic model uses Transformer-XL to take a sequence of music notes and predict the next note.

MultitaskTransformer - Built on top of MusicTransformer, this model is trained on multiple tasks.

  • Next Note Prediction (same as MusicTransformer)
  • BERT Token Masking
  • Sequence To Sequence Translation - Using chords to predict melody and vice versa.

Training on multiple tasks means we can generate some really cool predictions (Check out this Notebook):

  1. Harmonization - generate accompanying chords
  2. Melody - new melody from existing chord progression
  3. Remix tune - new song in the rhythm of a reference song
  4. Remix beat - same tune, different rhythm

How it works

Details are explained in this 4 part series:

  • Part I - Creating a Pop Music Generator
  • Part II - Implementation details
  • Part III - Multitask Transformer
  • Part IV - Composing a song with Multitask

Example Notebooks

  1. Play with predictions on Google Colab
  1. MusicTransformer
  • Train - End to end example on how to create a dataset from midi files and train a model from scratch
  • Generate - Loads a pretrained model and shows how to generate/predict new notes
  1. MultitaskTransformer
  • Train - End to end example on creating a seq2seq and masked dataset for multitask training.
  • Generate - Loads a pretrained model and shows how to harmonize, generate new melodies, and remix existing songs.
  1. Data Encoding
  • Midi2Tensor - Shows how the libary internally encodes midi files to tensors for training.
  • MusicItem - MusicItem is a wrapper that makes it easy to manipulate midi data. Convert midi to tensor, apply data transformations, even play music or display the notes within browser.

Pretrained Models

Pretrained models are available as MusicTransformer and MultitaskTransformer (small and large).

Each model has an additional keyC version. keyC means that the model has been trained solely on music transposed to the key of C (all white keys). These models produce better results, but expects the input to all be in the key of C.

  1. MusicTransformer (600 MB) - AnyKey | KeyC

  2. MultitaskTransformer

For details on how to load these models, follow the Generate and Multitask Generate notebooks

Source Code

Scripts

CLI scripts for training models:
run_multitask.py - multitask training

python run_multitask.py --epochs 14 --save multitask_model --batch_size=16 --bptt=512 --lamb --data_parallel --lr 1e-4

run_music_transformer.py - music model training

python run_music_transformer.py --epochs 14 --save music_model --batch_size=16 --bptt=512 --lr 1e-4

run_ddp.sh - Helper method to train with mulitple GPUs (DistributedDataParallel). Only works with run_music_transformer.py

SCRIPT=run_multitask.py bash run_ddp.sh --epochs 14 --save music_model --batch_size=16 --bptt=512 --lr 1e-4

Commands must be run inside the scripts/ folder

Installation

  1. Install anaconda: https://www.anaconda.com/distribution/

  2. Run:

git clone https://github.com/bearpelican/musicautobot.git

cd musicautobot

conda env update -f environment.yml

source activate musicautobot
  1. Install Musescore - to view sheet music within a jupyter notebook

    Ubuntu:

    sudo apt-get install musescore

    MacOS - download

Flask Server

Installation:

cd serve

conda env update -f environment.yml

S3 Bucket

You need to setup an s3 bucket to save your predictions. After you've created a bucket, update the config api/api.cfg with the new bucket name.

Development:

python run.py

Production:

gunicorn -b 127.0.0.1:5000 run_guni:app  --timeout 180 --workers 8

Data

Unfortunately I cannot provide the dataset used for training the model.

Here's some suggestions:

  • Classical Archives - incredible catalog of high quality classical midi
  • HookTheory - great data for sequence to sequence predictions. Need to manually copy files into hookpad
  • Reddit - 130k files
  • Lakh - great research dataset

Acknowledgements

This project is built on top of fast.ai's deep learning library and music21's incredible musicology library.

Inspired by bachbot and clara

Special thanks to SPC and PalapaVC

musicautobot's People

Contributors

bearpelican 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

musicautobot's Issues

installing error

when ever i put source activate musicautobot it just says "'source' is not recognized as an internal or external command,
operable program or batch file." so is there anyway to fix this? also how do you even run it even if it is installed correctly?

MusicTransformer error: Non midi note detected. Only returning valid portion. Index, seed 5 (50, 2)0/100 00:02<00:00]

Hi, I was wondering if someone might have some insight.

I've followed the "Train" notebook, but when I try to run it, I get the titular error. I am using the .mid files from "/data/midi/examples" as training data or a different set.The "Index, seed #" number changes on different runs.

Additionally, I cannot run the Generate notebook with the example.pth file generated either, it gives the following:

\learner.py", line 18, in music_model_learner
if config is None: config = state['config']
KeyError: 'config'

Everything is in 4/4 time

Everything seems to change to 4/4 time regardless of the original time signature, which I suppose is because 4/4 MIDIs are so much more numerous. Would training separately on other time signatures be the fix for this? (I haven't done any training myself.)

project

Can someone please implement this project in my local host? I can easily pay you.

Question about triplets, beat resolution, vocabulary size

I was wondering about the possibility of triplets. Musicautobot has a default beat grid of 16 steps in a 4/4 measure, or 4 pulses per quarter note. In order to encode eighth-note triplets (probably the shortest duration of triplet that would be useful), the beat grid would need to be 96 PPQN, i.e. 24 times as fine a resolution. Is that worth attempting, or would the much larger number of durations require too large a vocabulary?

Pretrained weights ?

Thanks for the repo, this is really neat !
Any chances you release pretrained weights to download ?

Thanks !

Is there a file missing or am I doing something wrong? FileNotFoundError: [Errno 2] No such file or directory: '/home/Project/musicautobot/data/numpy/musicitem_data_save.pkl'

I am trying to start the Flask server. This results in the following error message:

(base) felix@LAPTOP:~/Project/musicautobot/serve$ python run.py
Traceback (most recent call last):
  File "/home/felix/Project/musicautobot/serve/run.py", line 2, in <module>
    from api import app
  File "/home/felix/Project/musicautobot/serve/api/__init__.py", line 38, in <module>
    from .predict_multitask import *
  File "/home/felix/Project/musicautobot/serve/api/predict_multitask.py", line 16, in <module>
    data = load_data(app.config['DATA_PATH'], app.config['DATA_SAVE_NAME'], num_workers=1)
  File "/home/felix/anaconda3/lib/python3.9/site-packages/fastai/basic_data.py", line 281, in load_data
    ll = torch.load(source, map_location='cpu') if defaults.device == torch.device('cpu') else torch.load(source)
  File "/home/felix/anaconda3/lib/python3.9/site-packages/torch/serialization.py", line 699, in load
    with _open_file_like(f, 'rb') as opened_file:
  File "/home/felix/anaconda3/lib/python3.9/site-packages/torch/serialization.py", line 230, in _open_file_like
    return _open_file(name_or_buffer, mode)
  File "/home/felix/anaconda3/lib/python3.9/site-packages/torch/serialization.py", line 211, in __init__
    super(_open_file, self).__init__(open(name, mode))
FileNotFoundError: [Errno 2] No such file or directory: '/home/felix/Project/musicautobot/data/numpy/musicitem_data_save.pkl'

Since I didn't find a matching file in the repository, I just created an empty file, which doesn't do much either:

> (base) felix@LAPTOP:~/Project/musicautobot/serve$ python run.py
Traceback (most recent call last):
  File "/home/felix/Project/musicautobot/serve/run.py", line 2, in <module>
    from api import app
  File "/home/felix/Project/musicautobot/serve/api/__init__.py", line 38, in <module>
    from .predict_multitask import *
  File "/home/felix/Project/musicautobot/serve/api/predict_multitask.py", line 16, in <module>
    data = load_data(app.config['DATA_PATH'], app.config['DATA_SAVE_NAME'], num_workers=1)
  File "/home/felix/anaconda3/lib/python3.9/site-packages/fastai/basic_data.py", line 281, in load_data
    ll = torch.load(source, map_location='cpu') if defaults.device == torch.device('cpu') else torch.load(source)
  File "/home/felix/anaconda3/lib/python3.9/site-packages/torch/serialization.py", line 713, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/home/felix/anaconda3/lib/python3.9/site-packages/torch/serialization.py", line 920, in _legacy_load
    magic_number = pickle_module.load(f, **pickle_load_args)
EOFError: Ran out of input

I only edited the api.cfg file as follows, nothing more:

# Input bucket name only. Not the whole s3 URL
S3_BUCKET_NAME = 'MultitaskLarge'

How can I solve the problem? I followed the instructions in the readme file during the installation. Where is the error?

Error while importing music_transformer

Hi Andrew, I was running the Midi2Tensor notebook and there was a problem when importing music_transformer. I think the issue came from the append method in transform.py - I haven't tested it, but I think it might be fixed if you add a vocab argument.

Thanks for checking it out!

How to install this on Google colab?

Hi, I tried installing this package with

!git clone https://github.com/bearpelican/musicautobot.git

cd musicautobot

!wget https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh && bash Anaconda3-5.2.0-Linux-x86_64.sh -bfp /usr/local

import sys
sys.path.append('/usr/local/lib/python3.6/site-packages')

!conda env update -f environment.yml

!sudo apt-get install musescore

!source activate musicautobot

on colab, and run

%reload_ext autoreload
%autoreload 2
%matplotlib inline

import os
os.chdir('../../')

everything is fine, but importing musicautobot got me an error

from musicautobot.numpy_encode import *
from musicautobot.config import *
from musicautobot.music_transformer import *
from musicautobot.utils.midifile import *
from musicautobot.utils.file_processing import process_all

File "/content/musicautobot/musicautobot/music_transformer/transform.py", line 1
from future import annotations
^
SyntaxError: future feature annotations is not defined

Generating new melody to fit existing chord progression AND melodic rhythm?

Hi, I'm trying to use this project do something like what Hooktheory demonstrate in this video, and I'm not sure how to proceed. Basically, I want to take a MIDI file of a melody with an accompanying chord progression, and regenerate the pitches of the melody, while leaving the durations and the chord progression as they are--hopefully using the chord progression as a seed (if that's the right concept) for those new pitches.

Thanks a lot for this repo.

music_transformer issus

Thank you for your repo, it is brilliant!
I am new to this area and I have got several questions
1 I notitced the CLI scripts both for multitask training and music transformer training are runing run_multitask.py, so did you just discard run_music_transformer.py? If not, when I try to run this file, it pops several errors, are you gonna to fix that?
2 Is about the notebook scripts, I noticed that during the generate procedure, you still need to load the pretrained data pkl file , is that mean we need the pretrain data as well as the pretrained model to help us make prediction?
3. When I run the multitask_transformer/Generate.ipynb and to the line of:
pred_nw = learn.predict_nw(seed, n_words=200)
sometimes it shows it has been interrupted but if I try several times, finally it will work, any reason for that?
4 I try to use my own dataset to train, is there any restriction for the format, like minimum bas numbers? Does it has to be 2 tracks?
5 I try to train with your example midi files, sometime the prediction result will be empty, any suggestion for that?

Truly thankful for your reply!

Question about the Vocab

Hi,
Is there any chance you can add comment about the vocab token. Tokens like BOS, PAD are easy to understand, but Tokens like CSEQ, MSEQ, NSCLS are quite confusing.
By the way, why you decide to use tokens inside of using pure digital number. In another way to ask this question, why not just using idxenc to feed the model but using the "textify token" to feed the model.

Cheers!

What is the license?

Thanks for the repo, this is very impressive!
Can I use this code at work?
Can I use use the pre-trained model at work?
I would be happy if you could answer.
Thank you.

installing error

when ever i put "conda env update -f environment.yml" it just says "'conda' is not recognized as an internal or external command,
operable program or batch file." and if i put "source activate musicautobot" it just says "'source' is not recognized as an internal or external command, operable program or batch file." so is there anyways to fix this?

midifile.py classifies most tracks as undefined

When trying to preprocess my midi files (using the DataPreProcessing notebook), it keeps on returning None when

try: 
      # if duet_only and num_piano_tracks(input_path) not in [1, 2]: return None
       input_file = compress_midi_file(input_path, min_variation=min_variation, cutoff=cutoff) # remove non note tracks and standardize instruments

in the transform_midi function.

This leads to no conversion to npy's of my midi files

CUDA error: device-side assert triggered when trying to run the Train notebook

Hi
I have run into an error trying to replicate the train.ipynb notebook for the music transformer
I have installed the library using the instructions in the repo and tried to run the the notebook. the error:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-13-495233eaf2b4> in <module>
----> 1 learn.fit_one_cycle(4)

~/anaconda3/envs/musicautobot/lib/python3.7/site-packages/fastai/train.py in fit_one_cycle(learn, cyc_len, max_lr, moms, div_factor, pct_start, final_div, wd, callbacks, tot_epochs, start_epoch)
     21     callbacks.append(OneCycleScheduler(learn, max_lr, moms=moms, div_factor=div_factor, pct_start=pct_start,
     22                                        final_div=final_div, tot_epochs=tot_epochs, start_epoch=start_epoch))
---> 23     learn.fit(cyc_len, max_lr, wd=wd, callbacks=callbacks)
     24 
     25 def fit_fc(learn:Learner, tot_epochs:int=1, lr:float=defaults.lr,  moms:Tuple[float,float]=(0.95,0.85), start_pct:float=0.72,

~/anaconda3/envs/musicautobot/lib/python3.7/site-packages/fastai/basic_train.py in fit(self, epochs, lr, wd, callbacks)
    198         else: self.opt.lr,self.opt.wd = lr,wd
    199         callbacks = [cb(self) for cb in self.callback_fns + listify(defaults.extra_callback_fns)] + listify(callbacks)
--> 200         fit(epochs, self, metrics=self.metrics, callbacks=self.callbacks+callbacks)
    201 
    202     def create_opt(self, lr:Floats, wd:Floats=0.)->None:

~/anaconda3/envs/musicautobot/lib/python3.7/site-packages/fastai/basic_train.py in fit(epochs, learn, callbacks, metrics)
     99             for xb,yb in progress_bar(learn.data.train_dl, parent=pbar):
    100                 xb, yb = cb_handler.on_batch_begin(xb, yb)
--> 101                 loss = loss_batch(learn.model, xb, yb, learn.loss_func, learn.opt, cb_handler)
    102                 if cb_handler.on_batch_end(loss): break
    103 

~/anaconda3/envs/musicautobot/lib/python3.7/site-packages/fastai/basic_train.py in loss_batch(model, xb, yb, loss_func, opt, cb_handler)
     24     if not is_listy(xb): xb = [xb]
     25     if not is_listy(yb): yb = [yb]
---> 26     out = model(*xb)
     27     out = cb_handler.on_loss_begin(out)
     28 

~/anaconda3/envs/musicautobot/lib/python3.7/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    530             result = self._slow_forward(*input, **kwargs)
    531         else:
--> 532             result = self.forward(*input, **kwargs)
    533         for hook in self._forward_hooks.values():
    534             hook_result = hook(self, input, result)

~/anaconda3/envs/musicautobot/lib/python3.7/site-packages/torch/nn/modules/container.py in forward(self, input)
     98     def forward(self, input):
     99         for module in self:
--> 100             input = module(input)
    101         return input
    102 

~/anaconda3/envs/musicautobot/lib/python3.7/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    530             result = self._slow_forward(*input, **kwargs)
    531         else:
--> 532             result = self.forward(*input, **kwargs)
    533         for hook in self._forward_hooks.values():
    534             hook_result = hook(self, input, result)

/GW/Health-Corpus/work/nn/musicautobot/musicautobot/music_transformer/model.py in forward(self, x)
     33         seq_len = m_len + x_len
     34 
---> 35         mask = rand_window_mask(x_len, m_len, inp.device, max_size=self.mask_steps, is_eval=not self.training) if self.mask else None
     36         if m_len == 0: mask[...,0,0] = 0
     37         #[None,:,:None] for einsum implementation of attention

/GW/Health-Corpus/work/nn/musicautobot/musicautobot/utils/attention_mask.py in rand_window_mask(x_len, m_len, device, max_size, p, is_eval)
     15         win_size,k = (1,1)
     16     else: win_size,k = (np.random.randint(0,max_size)+1,0)
---> 17     return window_mask(x_len, device, m_len, size=(win_size,k))
     18 
     19 def lm_mask(x_len, device):

/GW/Health-Corpus/work/nn/musicautobot/musicautobot/utils/attention_mask.py in window_mask(x_len, device, m_len, size)
      6     mem_mask = torch.zeros((x_len,m_len), device=device)
      7     tri_mask = torch.triu(torch.ones((x_len//win_size+1,x_len//win_size+1), device=device),diagonal=k)
----> 8     window_mask = tri_mask.repeat_interleave(win_size,dim=0).repeat_interleave(win_size,dim=1)[:x_len,:x_len]
      9     if x_len: window_mask[...,0] = 0 # Always allowing first index to see. Otherwise you'll get NaN loss
     10     mask = torch.cat((mem_mask, window_mask), dim=1)[None,None]

RuntimeError: CUDA error: device-side assert triggered 

How can I run the code in windows without error like "NotImplementedError: cannot instantiate 'PosixPath' on your system"?

When I run run_multitask.py in Windows10, I met a path error:
NotImplementedError: cannot instantiate 'PosixPath' on your system
in the following code:
data = load_data(args.path, Path('piano_duet')/args.data_file, bs=args.batch_size, bptt=args.bptt, transpose_range=transpose_range, dl_tfms=mlm_tfm, num_workers=args.num_workers)
while it is fine in Linux.

can you help me to solve this problem? Thanks!

[Q] SCRIPT=run_gpt.py bash run_multi.sh ?

Dear Bearpelican,

What do you mean by "SCRIPT=run_gpt.py bash run_multi.sh" command?
If I use this@midi_generator-master dir,
$ SCRIPT=run_gpt.py bash run_multi.sh --path data/midi/midi_transcribe_v3_shortdur/ --batch_size 8 --lr .0001 --epochs 5 --save gpt/clc/v3ep50
/home/changhyk/anaconda3/envs/midi/bin/python: can't open file 'run_gpt.py': [Errno 2] No such file or directory
Traceback (most recent call last):
File "/home/changhyk/anaconda3/envs/midi/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/home/changhyk/anaconda3/envs/midi/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/changhyk/anaconda3/envs/midi/lib/python3.7/site-packages/torch/distributed/launch.py", line 235, in
main()
File "/home/changhyk/anaconda3/envs/midi/lib/python3.7/site-packages/torch/distributed/launch.py", line 231, in main
cmd=process.args)
subprocess.CalledProcessError: Command '['/home/changhyk/anaconda3/envs/midi/bin/python', '-u', 'run_gpt.py', '--local_rank=0', '--path', 'data/midi/midi_transcribe_v3_shortdur/', '--batch_size', '8', '--lr', '.0001', '--epochs', '5', '--save', 'gpt/clc/v3ep50']' returned non-zero exit status 2.

Any comment ?
Changhyun

Endless Loop & RuntimeError

In multitask_transformer, some strange things happened.

In both DataPreprocessing-Reddit ipynb (/music_transformer/) and DataPreprocessing-Reddit-Seq2seq ipynb (/multitask_transformer/),

when I executed 'processed = process_all(...)', it just continued running and never stopped, even clicking interrupt cell could not stop it.

In Train ipynb (/multitask_transformer/), RuntimeError likes Train ipynb in music_transformer when executing learn.fit.one_cycle(4) happened.

Reference for repeat penalty

Hi Andrew, thanks for the great code. In my own code for MIDI generation, at inference time, I tried your repeat penalty formula and it worked great. Do you have any references about this formula? (I mean if someone else came up with it before and published it). Thanks in advance.

In "notebooks/music_transformer/train.ipynb", data format mismatch

In #Show Data block, when execute
data.train_dl.on_epoch_begin()
x, y = data.one_batch();
x, y
the output format is like this:
(tensor( [ [ [ 0, 0],
[ 1, 0],
[77, 0], ...)
seems like load position info, which is different from the declared output:
(tensor([[ 0, 1, 76, 138, 64, 140, 59, 140, 57, 140, 8, 138],
[139, 75, 139, 8, 139, 73, 141, 8, 141, 70, 138, 8]]),
and lead to learn.fit_one_cycle(4) to crash:
in music_transformer/model.py
def forward:
...
bs, x_len = x.size() to many value to unpack

how should I fix this bug?
big thx!

An example of training directly from .txt files?

I'm wondering if there's an example of training from .txt files? I have my own representation, from which I'm generating .txt files from MIDI. I just need a bit of guidance on how I'd go about formatting these for the multitask transformer.

Any advice appreciated!

RunTimeError & ValueError

I got the same RunTimeError when I tried to execute learn.predict in both "Generate" and "Train" ipynb. All of the cells above the "predict" cells worked just fine. Besides, I got ValueError in "Train-Simple" ipynb. All of the cells above the "learn.fit_one_cycle(4)" cells worked just fine. I wonder is it only me that encountered these problems.

In /notebooks/music_transformer/Generate.ipynb

pred, full = learn.predict(seed_item, n_words=400, temperatures=(1.1,0.4), min_bars=12, top_k=24, top_p=0.7)

RuntimeError: Expected tensor for argument #1 'indices' to have scalar type Long; but got torch.cuda.IntTensor instead (while checking arguments for embedding)

In /notebooks/music_transformer/Train.ipynb

pred, full = learn.predict(item, n_words=100)

RuntimeError: Expected tensor for argument #1 'indices' to have scalar type Long; but got torch.cuda.IntTensor instead (while checking arguments for embedding)

In /notebooks/music_transformer/Train-Simple.ipynb

learn.fit_one_cycle(4)

ValueError: too many values to unpack (expected 2)

Attempting to add extended context to the seq2seq model

So I want to use the large seq2seq model to create some music, but then I found out that it is extremely memory consuming and I can only input a mere 16 bars into the network.

However, I have this idea that if I can input the next 32 bars into the decoder as the context, it might perform better since we are working with the Transformer-XL. But I've tried many ways to add it in and its either totally not working or at best yielding the exact same behaviour as before. So, is there a simple way to add this?

Any way to finetune?

This is such an interesting work. I hope I could finetune the model to generate particular type of genre and I want to listen to your suggestions. For example, I prepared a small set of jazz songs and attempt to train a little before I infer a new jazz song, where would you recommend to extend for the code?

Appreciate your help
Best,

Excepting Noisy Data?

When I was trying to use the code provided in the guide on my own dataset (the Reddit one), I ran into a problem:
music21.midi.MidiException: badly formated midi bytes, got: b'<html>\r\n<head>\r\n<tit'
which is definitely an error in the midi files because the examples provided in the repository works.

Thus, I'm just curious if there is a way to skip these files - to make the code work even if there are less samples available.

Here is my code:
`midi_path = Path('data/midi/')

Location to save dataset

data_path = Path('data/numpy')

data_save_name = 'musicitem_data_save.pkl'
midi_files = get_files(midi_path, '.mid', recurse=True)

processors = [Midi2ItemProcessor()]
data = MusicDataBunch.from_files(midi_files, data_path, processors=[Midi2ItemProcessor()], bs=16, bptt=512,
encode_position=True, dl_tfms=[batch_position_tfm])
data.save(data_save_name)`

Beat and Bar Encoding in Transformer Encoder Question

Hi, this line of code seems redundant since bar_pos is already < self.max_bar_len by the line above.

Also I am a little bit confused about the default value of beat_len=32 and max_bar_len=1024. beat_len=4 makes more sense in my opinion since the value will loop every quarter note. Could you please give me more details?

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.