asigalov61
commited on
Commit
•
c80330f
1
Parent(s):
f811ed6
Update app.py
Browse files
app.py
CHANGED
@@ -60,8 +60,54 @@ def generate(
|
|
60 |
|
61 |
else:
|
62 |
return out[:, st:]
|
|
|
|
|
63 |
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
#=================================================================================================
|
66 |
|
67 |
|
@@ -109,7 +155,7 @@ if __name__ == "__main__":
|
|
109 |
|
110 |
providers = ['CPUExecutionProvider']
|
111 |
|
112 |
-
session = rt.InferenceSession('Allegro_Music_Transformer_Small_Trained_Model_56000_steps_0.9399_loss_0.7374_acc.onnx', providers=providers)
|
113 |
|
114 |
app = gr.Blocks()
|
115 |
with app:
|
|
|
60 |
|
61 |
else:
|
62 |
return out[:, st:]
|
63 |
+
|
64 |
+
#=================================================================================================
|
65 |
|
66 |
+
def GenerateMIDI(params):
|
67 |
+
|
68 |
+
melody_chords_f = generate([3087, 3073+1, 3075+1], 512)
|
69 |
+
|
70 |
+
melody_chords_f = melody_chords_f.tolist()[0]
|
71 |
+
|
72 |
+
print('=' * 70)
|
73 |
+
print('Sample INTs', melody_chords_f[:12])
|
74 |
+
print('=' * 70)
|
75 |
+
|
76 |
+
if len(melody_chords_f) != 0:
|
77 |
+
|
78 |
+
song = melody_chords_f
|
79 |
+
song_f = []
|
80 |
+
time = 0
|
81 |
+
dur = 0
|
82 |
+
vel = 0
|
83 |
+
pitch = 0
|
84 |
+
channel = 0
|
85 |
+
|
86 |
+
for ss in song:
|
87 |
+
|
88 |
+
if ss > 0 and ss < 256:
|
89 |
+
|
90 |
+
time += ss * 8
|
91 |
+
|
92 |
+
if ss >= 256 and ss < 1280:
|
93 |
+
|
94 |
+
dur = ((ss-256) // 8) * 32
|
95 |
+
vel = (((ss-256) % 8)+1) * 15
|
96 |
+
|
97 |
+
if ss >= 1280 and ss < 2816:
|
98 |
+
channel = (ss-1280) // 128
|
99 |
+
pitch = (ss-1280) % 128
|
100 |
+
|
101 |
+
song_f.append(['note', time, dur, channel, pitch, vel ])
|
102 |
+
|
103 |
+
detailed_stats = TMIDIX.Tegridy_SONG_to_MIDI_Converter(song_f,
|
104 |
+
output_signature = 'Allegro Music Transformer',
|
105 |
+
output_file_name = 'Allegro-Music-Transformer-Music-Composition',
|
106 |
+
track_name='Project Los Angeles',
|
107 |
+
list_of_MIDI_patches=[0, 24, 32, 40, 42, 46, 56, 71, 73, 0, 53, 19, 0, 0, 0, 0],
|
108 |
+
number_of_ticks_per_quarter=500)
|
109 |
+
print('=' * 70)
|
110 |
+
|
111 |
#=================================================================================================
|
112 |
|
113 |
|
|
|
155 |
|
156 |
providers = ['CPUExecutionProvider']
|
157 |
|
158 |
+
# session = rt.InferenceSession('Allegro_Music_Transformer_Small_Trained_Model_56000_steps_0.9399_loss_0.7374_acc.onnx', providers=providers)
|
159 |
|
160 |
app = gr.Blocks()
|
161 |
with app:
|