Upload main.py
Browse files
main.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from model import PopMusicTransformer
|
2 |
+
import os
|
3 |
+
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
|
4 |
+
|
5 |
+
def main():
|
6 |
+
# declare model
|
7 |
+
model = PopMusicTransformer(
|
8 |
+
checkpoint='REMI-tempo-checkpoint',
|
9 |
+
is_training=False)
|
10 |
+
|
11 |
+
# generate from scratch
|
12 |
+
model.generate(
|
13 |
+
n_target_bar=16,
|
14 |
+
temperature=1.2,
|
15 |
+
topk=5,
|
16 |
+
output_path='./result/from_scratch.midi',
|
17 |
+
prompt=None)
|
18 |
+
|
19 |
+
# generate continuation
|
20 |
+
model.generate(
|
21 |
+
n_target_bar=16,
|
22 |
+
temperature=1.2,
|
23 |
+
topk=5
|
24 |
+
output_path='./result/continuation.midi',
|
25 |
+
prompt='./data/evaluation/000.midi')
|
26 |
+
|
27 |
+
# close model
|
28 |
+
model.close()
|
29 |
+
|
30 |
+
if __name__ == '__main__':
|
31 |
+
main()
|