Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -56,21 +56,13 @@ print('=' * 70)
|
|
56 |
|
57 |
#==================================================================================
|
58 |
|
59 |
-
MODEL_CHECKPOINTS =
|
60 |
-
'with velocity - 3 epochs': 'Monster_Piano_Transformer_Velocity_Trained_Model_59896_steps_0.9055_loss_0.735_acc.pth',
|
61 |
-
'without velocity - 3 epochs': 'Monster_Piano_Transformer_No_Velocity_Trained_Model_69412_steps_0.8577_loss_0.7442_acc.pth',
|
62 |
-
'without velocity - 7 epochs': 'Monster_Piano_Transformer_No_Velocity_Trained_Model_161960_steps_0.7775_loss_0.7661_acc.pth'
|
63 |
-
}
|
64 |
|
65 |
SOUDFONT_PATH = 'SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2'
|
66 |
|
67 |
-
NUM_OUT_BATCHES = 12
|
68 |
-
|
69 |
-
PREVIEW_LENGTH = 120 # in tokens
|
70 |
-
|
71 |
#==================================================================================
|
72 |
|
73 |
-
def load_model(
|
74 |
|
75 |
print('=' * 70)
|
76 |
print('Instantiating model...')
|
@@ -206,14 +198,10 @@ def save_midi(tokens, batch_number=None, model_selector=''):
|
|
206 |
#==================================================================================
|
207 |
|
208 |
@spaces.GPU
|
209 |
-
def
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
model_temperature,
|
214 |
-
# model_sampling_top_p,
|
215 |
-
model_state
|
216 |
-
):
|
217 |
|
218 |
if not prime:
|
219 |
inputs = [0]
|
@@ -391,26 +379,6 @@ def generate_callback_wrapper(input_midi,
|
|
391 |
|
392 |
#==================================================================================
|
393 |
|
394 |
-
def reset(final_composition=[], generated_batches=[], block_lines=[], model_state=[]):
|
395 |
-
|
396 |
-
final_composition = []
|
397 |
-
generated_batches = []
|
398 |
-
block_lines = []
|
399 |
-
model_state = []
|
400 |
-
|
401 |
-
return final_composition, generated_batches, block_lines
|
402 |
-
|
403 |
-
#==================================================================================
|
404 |
-
|
405 |
-
def reset_demo(final_composition=[], generated_batches=[], block_lines=[], model_state=[]):
|
406 |
-
|
407 |
-
final_composition = []
|
408 |
-
generated_batches = []
|
409 |
-
block_lines = []
|
410 |
-
model_state = []
|
411 |
-
|
412 |
-
#==================================================================================
|
413 |
-
|
414 |
PDT = timezone('US/Pacific')
|
415 |
|
416 |
print('=' * 70)
|
@@ -470,7 +438,7 @@ with gr.Blocks() as demo:
|
|
470 |
generate_btn.click(generate_accompaniment,
|
471 |
[input_midi,
|
472 |
num_gen_tokens,
|
473 |
-
model_temperature
|
474 |
],
|
475 |
[
|
476 |
output_audio,
|
|
|
56 |
|
57 |
#==================================================================================
|
58 |
|
59 |
+
MODEL_CHECKPOINTS = 'Guided_Accompaniment_Transformer_Trained_Model_59896_steps_0.9055_loss_0.735_acc.pth'
|
|
|
|
|
|
|
|
|
60 |
|
61 |
SOUDFONT_PATH = 'SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2'
|
62 |
|
|
|
|
|
|
|
|
|
63 |
#==================================================================================
|
64 |
|
65 |
+
def load_model():
|
66 |
|
67 |
print('=' * 70)
|
68 |
print('Instantiating model...')
|
|
|
198 |
#==================================================================================
|
199 |
|
200 |
@spaces.GPU
|
201 |
+
def generate_accompaniment(input_midi,
|
202 |
+
num_gen_tokens,
|
203 |
+
model_temperature
|
204 |
+
):
|
|
|
|
|
|
|
|
|
205 |
|
206 |
if not prime:
|
207 |
inputs = [0]
|
|
|
379 |
|
380 |
#==================================================================================
|
381 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
382 |
PDT = timezone('US/Pacific')
|
383 |
|
384 |
print('=' * 70)
|
|
|
438 |
generate_btn.click(generate_accompaniment,
|
439 |
[input_midi,
|
440 |
num_gen_tokens,
|
441 |
+
model_temperature
|
442 |
],
|
443 |
[
|
444 |
output_audio,
|