Comments (9)
You can use glob to grab your midi files! We can pull out extract_events
from model.py
to make the dictionary.
from collections import Counter
import pickle
import glob
import utils
def extract_events(input_path, chord=False):
note_items, tempo_items = utils.read_items(input_path)
note_items = utils.quantize_items(note_items)
max_time = note_items[-1].end
if chord:
chord_items = utils.extract_chords(note_items)
items = chord_items + tempo_items + note_items
else:
items = tempo_items + note_items
groups = utils.group_items(items, max_time)
events = utils.item2event(groups)
return events
all_elements= []
for midi_file in glob.glob("./data/*/*.mid*", recursive=True):
events = extract_events(midi_file) # If you're analyzing chords, use `extract_events(midi_file, chord=True)`
for event in events:
element = '{}_{}'.format(event.name, event.value)
all_elements.append(element)
counts = Counter(all_elements)
event2word = {c: i for i, c in enumerate(counts.keys())}
word2event = {i: c for i, c in enumerate(counts.keys())}
pickle.dump((event2word, word2event), open('dictionary.pkl', 'wb'))
This grabs all files in the data
folder with file extensions that start with .mid
(This covers .mid
and .midi
files).
from remi.
Same problem here
from remi.
from collections import Counter
import pickle
all_elements= []
for midi_file in you_all_midi_files:
events = model.extract_events(midi_file)
for event in events:
element = '{}_{}'.format(event.name, event.value)
all_elements.append(element)
counts = Counter(all_elements)
event2word = {c: i for i, c in enumerate(counts.keys())}
word2event = {i: c for i, c in enumerate(counts.keys())}
pickle.dump((event2word, word2event), open('dictionary.pkl', 'wb'))
I’m not sure if you can run it directly, but it should be easy for you to modify.
from remi.
Thank you for the amazing work on this project!
However, I have a problem for several days and would like to ask for help, I was able to generate my own music training dictionary according to the above code, but it does not work with the original REMI-tempo-checkpoint (I am directly replacing the previous dictionary with my own) and then the following error occurs:
In addition, can I use my own training data to generate my own checkpoint and evaluation my own music?
Do you have any insights about this problem?
Thanks again for your kind help!
from remi.
感谢您在这个项目上所做的出色工作!
但是我这几天有问题想求助,我可以按照上面的代码生成自己的音乐训练字典,但是用原来的REMI-tempo-checkpoint不行(我直接用我自己的字典替换以前的字典),然后出现以下错误:
另外,我可以使用自己的训练数据来生成自己的检查点并评估自己的音乐吗? 你对这个问题有什么见解吗?
再次感谢您的帮助!
Hello, have you solved this problem? I have the same problem
from remi.
您可以使用 glob 来获取您的 MIDI 文件!我们可以从中取出来
extract_events
制作model.py
字典。from collections import Counter import pickle import glob import utils def extract_events(input_path, chord=False): note_items, tempo_items = utils.read_items(input_path) note_items = utils.quantize_items(note_items) max_time = note_items[-1].end if chord: chord_items = utils.extract_chords(note_items) items = chord_items + tempo_items + note_items else: items = tempo_items + note_items groups = utils.group_items(items, max_time) events = utils.item2event(groups) return events all_elements= [] for midi_file in glob.glob("./data/*/*.mid*", recursive=True): events = extract_events(midi_file) # If you're analyzing chords, use `extract_events(midi_file, chord=True)` for event in events: element = '{}_{}'.format(event.name, event.value) all_elements.append(element) counts = Counter(all_elements) event2word = {c: i for i, c in enumerate(counts.keys())} word2event = {i: c for i, c in enumerate(counts.keys())} pickle.dump((event2word, word2event), open('dictionary.pkl', 'wb'))
这将抓取文件
data
夹中文件扩展名以.mid
(This cover.mid
and.midi
files) 开头的所有文件。
您可以使用 glob 来获取您的 MIDI 文件!我们可以从中取出来
extract_events
制作model.py
字典。from collections import Counter import pickle import glob import utils def extract_events(input_path, chord=False): note_items, tempo_items = utils.read_items(input_path) note_items = utils.quantize_items(note_items) max_time = note_items[-1].end if chord: chord_items = utils.extract_chords(note_items) items = chord_items + tempo_items + note_items else: items = tempo_items + note_items groups = utils.group_items(items, max_time) events = utils.item2event(groups) return events all_elements= [] for midi_file in glob.glob("./data/*/*.mid*", recursive=True): events = extract_events(midi_file) # If you're analyzing chords, use `extract_events(midi_file, chord=True)` for event in events: element = '{}_{}'.format(event.name, event.value) all_elements.append(element) counts = Counter(all_elements) event2word = {c: i for i, c in enumerate(counts.keys())} word2event = {i: c for i, c in enumerate(counts.keys())} pickle.dump((event2word, word2event), open('dictionary.pkl', 'wb'))
这将抓取文件
data
夹中文件扩展名以.mid
(This cover.mid
and.midi
files) 开头的所有文件。
Hello, why do I report an error when using my MIDI data to generate a dictionary? In the case of multiple MIDI, it will report an error, but one or two will be fine. What's the use of a dictionary
from remi.
from collections import Counter import pickle all_elements = [] 用于 you_all_midi_files 中的 midi_file: 事件 = 模型。extract_events ( midi_file ) 用于 事件 中的 事件: element = '{}_{}'。格式(事件。名称,事件。值) all_elements。附加(元素) counts = Counter ( all_elements ) event2word = { c : i for i , c in enumerate ( counts.keys ( ) )} word2event = { i : c for i , c in enumerate ( counts.keys ( ) ) } pickle。转储((event2word,word2event),打开('dictionary.pkl' , 'wb' ))我不确定你是否可以直接运行它,但它应该很容易修改。
Must a dictionary of the same size as the pre training checkpoint be generated
from remi.
您可以使用 glob 来获取您的 MIDI 文件!我们可以从中取出来
extract_events
制作model.py
字典。from collections import Counter import pickle import glob import utils def extract_events(input_path, chord=False): note_items, tempo_items = utils.read_items(input_path) note_items = utils.quantize_items(note_items) max_time = note_items[-1].end if chord: chord_items = utils.extract_chords(note_items) items = chord_items + tempo_items + note_items else: items = tempo_items + note_items groups = utils.group_items(items, max_time) events = utils.item2event(groups) return events all_elements= [] for midi_file in glob.glob("./data/*/*.mid*", recursive=True): events = extract_events(midi_file) # If you're analyzing chords, use `extract_events(midi_file, chord=True)` for event in events: element = '{}_{}'.format(event.name, event.value) all_elements.append(element) counts = Counter(all_elements) event2word = {c: i for i, c in enumerate(counts.keys())} word2event = {i: c for i, c in enumerate(counts.keys())} pickle.dump((event2word, word2event), open('dictionary.pkl', 'wb'))
这将抓取文件
data
夹中文件扩展名以.mid
(This cover.mid
and.midi
files) 开头的所有文件。
Do you have to generate a dictionary of the same size as the pre training checkpoint to train your own data
from remi.
Just for the record, this discuss only for train task from scratch. If you use finetune.py to train your model,just need copy the original dictionary.pkl from pretrain document.
from remi.
Related Issues (20)
- Issues when training with other datasets HOT 1
- Issues with evaluation (std and salience for beat/downbeat) HOT 6
- questions about model.py HOT 1
- midi2remi is not run
- something is wrong! Tempo Value_57 HOT 7
- MIDI files end up their last note pushed up a position HOT 6
- Checkpoints saved with a NAN value HOT 2
- i can't train from scratch after remove line 99 HOT 1
- How can I train my MIDI dataset
- Process finished with exit code -1073741571 (0xC00000FD)
- How do I generate my own Remi-checkpoint
- style question
- dictionary.pkl HOT 1
- evaluation code
- Questions about beat and downbeat
- self.group_size*2 should be self.group_size in prepare_data()
- .pb file output
- problem when using REMI-tempo-chord-checkpoint
- More detailed information about finetuning data format HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from remi.