Spaces:
Running
on
Zero
Running
on
Zero
asigalov61
commited on
Commit
•
15d8aad
1
Parent(s):
f4d6d33
Update app.py
Browse files
app.py
CHANGED
@@ -128,7 +128,9 @@ print('=' * 70)
|
|
128 |
def Generate_POP_Section(input_comp_section,
|
129 |
input_mode_time,
|
130 |
input_mode_dur,
|
131 |
-
input_mode_ptc
|
|
|
|
|
132 |
):
|
133 |
|
134 |
print('=' * 70)
|
@@ -142,6 +144,8 @@ def Generate_POP_Section(input_comp_section,
|
|
142 |
print('Mode time:', input_mode_time)
|
143 |
print('Mode duration:', input_mode_dur)
|
144 |
print('Mode pitch:', input_mode_ptc)
|
|
|
|
|
145 |
print('=' * 70)
|
146 |
|
147 |
#===============================================================================
|
@@ -174,9 +178,9 @@ def Generate_POP_Section(input_comp_section,
|
|
174 |
|
175 |
out = model.generate(x,
|
176 |
512-len(seq),
|
177 |
-
temperature=
|
178 |
filter_logits_fn=top_p,
|
179 |
-
filter_kwargs={'thres':
|
180 |
eos_token=917,
|
181 |
return_prime=True,
|
182 |
verbose=True)
|
@@ -202,7 +206,7 @@ def Generate_POP_Section(input_comp_section,
|
|
202 |
comp_summary += 'Generated section: ' + str(comp_section) + '\n'
|
203 |
comp_summary += 'Generated mode time: ' + str(comp_mode_time) + '\n'
|
204 |
comp_summary += 'Generated mode duration: ' + str(comp_mode_dur) + '\n'
|
205 |
-
comp_summary += 'Generated mode pitch
|
206 |
|
207 |
print('Sample INTs', song[:5])
|
208 |
print('=' * 70)
|
@@ -273,7 +277,7 @@ def Generate_POP_Section(input_comp_section,
|
|
273 |
|
274 |
print('Output MIDI file name:', output_midi)
|
275 |
print('Output MIDI title:', output_midi_title)
|
276 |
-
print('Output MIDI summary', comp_summary)
|
277 |
print('=' * 70)
|
278 |
|
279 |
|
@@ -318,6 +322,8 @@ if __name__ == "__main__":
|
|
318 |
input_mode_time = gr.Slider(0, 127, value=0, step=1, label="Composition mode time")
|
319 |
input_mode_dur = gr.Slider(0, 127, value=0, step=1, label="Composition mode dur")
|
320 |
input_mode_ptc = gr.Slider(0, 127, value=0, step=1, label="Composition mode pitch")
|
|
|
|
|
321 |
|
322 |
run_btn = gr.Button("Generate", variant="primary")
|
323 |
|
@@ -332,7 +338,9 @@ if __name__ == "__main__":
|
|
332 |
run_event = run_btn.click(Generate_POP_Section, [input_comp_section,
|
333 |
input_mode_time,
|
334 |
input_mode_dur,
|
335 |
-
input_mode_ptc
|
|
|
|
|
336 |
],
|
337 |
[output_midi_title,
|
338 |
output_midi_summary,
|
@@ -341,12 +349,16 @@ if __name__ == "__main__":
|
|
341 |
output_plot]
|
342 |
)
|
343 |
|
344 |
-
gr.Examples([["intro", 10, 15,
|
|
|
|
|
345 |
],
|
346 |
[input_comp_section,
|
347 |
input_mode_time,
|
348 |
input_mode_dur,
|
349 |
-
input_mode_ptc
|
|
|
|
|
350 |
],
|
351 |
[output_midi_title,
|
352 |
output_midi_summary,
|
|
|
128 |
def Generate_POP_Section(input_comp_section,
|
129 |
input_mode_time,
|
130 |
input_mode_dur,
|
131 |
+
input_mode_ptc,
|
132 |
+
input_model_temp,
|
133 |
+
input_model_top_p
|
134 |
):
|
135 |
|
136 |
print('=' * 70)
|
|
|
144 |
print('Mode time:', input_mode_time)
|
145 |
print('Mode duration:', input_mode_dur)
|
146 |
print('Mode pitch:', input_mode_ptc)
|
147 |
+
print('Model temperature:', input_model_temp)
|
148 |
+
print('Model top p:', input_model_top_p)
|
149 |
print('=' * 70)
|
150 |
|
151 |
#===============================================================================
|
|
|
178 |
|
179 |
out = model.generate(x,
|
180 |
512-len(seq),
|
181 |
+
temperature=input_model_temp,
|
182 |
filter_logits_fn=top_p,
|
183 |
+
filter_kwargs={'thres': input_model_top_p},
|
184 |
eos_token=917,
|
185 |
return_prime=True,
|
186 |
verbose=True)
|
|
|
206 |
comp_summary += 'Generated section: ' + str(comp_section) + '\n'
|
207 |
comp_summary += 'Generated mode time: ' + str(comp_mode_time) + '\n'
|
208 |
comp_summary += 'Generated mode duration: ' + str(comp_mode_dur) + '\n'
|
209 |
+
comp_summary += 'Generated mode pitch: ' + str(comp_mode_ptc)
|
210 |
|
211 |
print('Sample INTs', song[:5])
|
212 |
print('=' * 70)
|
|
|
277 |
|
278 |
print('Output MIDI file name:', output_midi)
|
279 |
print('Output MIDI title:', output_midi_title)
|
280 |
+
print('Output MIDI summary:', comp_summary)
|
281 |
print('=' * 70)
|
282 |
|
283 |
|
|
|
322 |
input_mode_time = gr.Slider(0, 127, value=0, step=1, label="Composition mode time")
|
323 |
input_mode_dur = gr.Slider(0, 127, value=0, step=1, label="Composition mode dur")
|
324 |
input_mode_ptc = gr.Slider(0, 127, value=0, step=1, label="Composition mode pitch")
|
325 |
+
input_model_temp = gr.Slider(0.1, 1, value=0.9, step=0.01, label="Model temperature")
|
326 |
+
input_model_top_p = gr.Slider(0.1, 1, value=0.96, step=0.01, label="Model sampling top p value")
|
327 |
|
328 |
run_btn = gr.Button("Generate", variant="primary")
|
329 |
|
|
|
338 |
run_event = run_btn.click(Generate_POP_Section, [input_comp_section,
|
339 |
input_mode_time,
|
340 |
input_mode_dur,
|
341 |
+
input_mode_ptc,
|
342 |
+
input_model_temp,
|
343 |
+
input_model_top_p
|
344 |
],
|
345 |
[output_midi_title,
|
346 |
output_midi_summary,
|
|
|
349 |
output_plot]
|
350 |
)
|
351 |
|
352 |
+
gr.Examples([["intro", 10, 15, 72, 0.9, 0.96],
|
353 |
+
["chorus", 10, 15, 72, 0.9, 0.96],
|
354 |
+
["bridge", 10, 15, 72, 0.9, 0.96]
|
355 |
],
|
356 |
[input_comp_section,
|
357 |
input_mode_time,
|
358 |
input_mode_dur,
|
359 |
+
input_mode_ptc,
|
360 |
+
input_model_temp,
|
361 |
+
input_model_top_p
|
362 |
],
|
363 |
[output_midi_title,
|
364 |
output_midi_summary,
|