Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
#==================================================================================
|
2 |
-
# https://huggingface.co/spaces/asigalov61/
|
3 |
#==================================================================================
|
4 |
|
5 |
print('=' * 70)
|
6 |
-
print('
|
7 |
|
8 |
print('=' * 70)
|
9 |
-
print('Loading core
|
10 |
|
11 |
import os
|
12 |
|
@@ -15,7 +15,7 @@ import datetime
|
|
15 |
from pytz import timezone
|
16 |
|
17 |
print('=' * 70)
|
18 |
-
print('Loading main
|
19 |
|
20 |
os.environ['USE_FLASH_ATTENTION'] = '1'
|
21 |
|
@@ -40,7 +40,7 @@ from x_transformer_1_23_2 import *
|
|
40 |
import random
|
41 |
|
42 |
print('=' * 70)
|
43 |
-
print('Loading aux
|
44 |
|
45 |
import matplotlib.pyplot as plt
|
46 |
|
@@ -244,13 +244,13 @@ def save_midi(tokens, batch_number=None):
|
|
244 |
patches = [0 if x==-1 else x for x in patches]
|
245 |
|
246 |
if batch_number == None:
|
247 |
-
fname = '
|
248 |
|
249 |
else:
|
250 |
-
fname = '
|
251 |
|
252 |
data = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(song_f,
|
253 |
-
output_signature = '
|
254 |
output_file_name = fname,
|
255 |
track_name='Project Los Angeles',
|
256 |
list_of_MIDI_patches=patches,
|
@@ -382,7 +382,7 @@ def generate_callback(input_midi,
|
|
382 |
)
|
383 |
|
384 |
# File name
|
385 |
-
fname = '
|
386 |
|
387 |
# Save audio to a temporary file
|
388 |
midi_audio = midi_to_colab_audio(fname + '.mid',
|
@@ -467,12 +467,12 @@ def add_batch(batch_number, final_composition, generated_batches, block_lines):
|
|
467 |
|
468 |
# MIDI plot
|
469 |
midi_plot = TMIDIX.plot_ms_SONG(midi_score,
|
470 |
-
plot_title='
|
471 |
block_lines_times_list=block_lines[:-1],
|
472 |
return_plt=True)
|
473 |
|
474 |
# File name
|
475 |
-
fname = '
|
476 |
|
477 |
# Save audio to a temporary file
|
478 |
midi_audio = midi_to_colab_audio(fname + '.mid',
|
@@ -504,12 +504,12 @@ def remove_batch(batch_number, num_tokens, final_composition, generated_batches,
|
|
504 |
|
505 |
# MIDI plot
|
506 |
midi_plot = TMIDIX.plot_ms_SONG(midi_score,
|
507 |
-
plot_title='
|
508 |
block_lines_times_list=block_lines[:-1],
|
509 |
return_plt=True)
|
510 |
|
511 |
# File name
|
512 |
-
fname = '
|
513 |
|
514 |
# Save audio to a temporary file
|
515 |
midi_audio = midi_to_colab_audio(fname + '.mid',
|
@@ -556,16 +556,16 @@ with gr.Blocks() as demo:
|
|
556 |
|
557 |
demo.load(reset_demo)
|
558 |
|
559 |
-
gr.Markdown("<h1 style='text-align: center; margin-bottom: 1rem'>
|
560 |
-
gr.Markdown("<h1 style='text-align: center; margin-bottom: 1rem'>
|
561 |
gr.HTML("""
|
562 |
-
Check out <a href="https://github.com/asigalov61/
|
563 |
|
564 |
<p>
|
565 |
-
<a href="https://colab.research.google.com/github/asigalov61/
|
566 |
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab">
|
567 |
</a> or
|
568 |
-
<a href="https://huggingface.co/spaces/asigalov61/
|
569 |
<img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-md.svg" alt="Duplicate in Hugging Face">
|
570 |
</a>
|
571 |
</p>
|
|
|
1 |
#==================================================================================
|
2 |
+
# https://huggingface.co/spaces/asigalov61/Monster-Piano-Transformer
|
3 |
#==================================================================================
|
4 |
|
5 |
print('=' * 70)
|
6 |
+
print('Monster Piano Transformer Gradio App')
|
7 |
|
8 |
print('=' * 70)
|
9 |
+
print('Loading core Monster Piano Transformer modules...')
|
10 |
|
11 |
import os
|
12 |
|
|
|
15 |
from pytz import timezone
|
16 |
|
17 |
print('=' * 70)
|
18 |
+
print('Loading main Monster Piano Transformer modules...')
|
19 |
|
20 |
os.environ['USE_FLASH_ATTENTION'] = '1'
|
21 |
|
|
|
40 |
import random
|
41 |
|
42 |
print('=' * 70)
|
43 |
+
print('Loading aux Monster Piano Transformer modules...')
|
44 |
|
45 |
import matplotlib.pyplot as plt
|
46 |
|
|
|
244 |
patches = [0 if x==-1 else x for x in patches]
|
245 |
|
246 |
if batch_number == None:
|
247 |
+
fname = 'Monster-Piano-Transformer-Music-Composition'
|
248 |
|
249 |
else:
|
250 |
+
fname = 'Monster-Piano-Transformer-Music-Composition_'+str(batch_number)
|
251 |
|
252 |
data = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(song_f,
|
253 |
+
output_signature = 'Monster Piano Transformer',
|
254 |
output_file_name = fname,
|
255 |
track_name='Project Los Angeles',
|
256 |
list_of_MIDI_patches=patches,
|
|
|
382 |
)
|
383 |
|
384 |
# File name
|
385 |
+
fname = 'Monster-Piano-Transformer-Music-Composition_'+str(i)
|
386 |
|
387 |
# Save audio to a temporary file
|
388 |
midi_audio = midi_to_colab_audio(fname + '.mid',
|
|
|
467 |
|
468 |
# MIDI plot
|
469 |
midi_plot = TMIDIX.plot_ms_SONG(midi_score,
|
470 |
+
plot_title='Monster Piano Transformer Composition',
|
471 |
block_lines_times_list=block_lines[:-1],
|
472 |
return_plt=True)
|
473 |
|
474 |
# File name
|
475 |
+
fname = 'Monster-Piano-Transformer-Music-Composition'
|
476 |
|
477 |
# Save audio to a temporary file
|
478 |
midi_audio = midi_to_colab_audio(fname + '.mid',
|
|
|
504 |
|
505 |
# MIDI plot
|
506 |
midi_plot = TMIDIX.plot_ms_SONG(midi_score,
|
507 |
+
plot_title='Monster Piano Transformer Composition',
|
508 |
block_lines_times_list=block_lines[:-1],
|
509 |
return_plt=True)
|
510 |
|
511 |
# File name
|
512 |
+
fname = 'Monster-Piano-Transformer-Music-Composition'
|
513 |
|
514 |
# Save audio to a temporary file
|
515 |
midi_audio = midi_to_colab_audio(fname + '.mid',
|
|
|
556 |
|
557 |
demo.load(reset_demo)
|
558 |
|
559 |
+
gr.Markdown("<h1 style='text-align: center; margin-bottom: 1rem'>Monster Piano Transformer</h1>")
|
560 |
+
gr.Markdown("<h1 style='text-align: center; margin-bottom: 1rem'>Ultra-fast and very well fitted solo Piano music transformer</h1>")
|
561 |
gr.HTML("""
|
562 |
+
Check out <a href="https://github.com/asigalov61/monsterpianotransformer">Monster Piano Transformer</a> on GitHub!
|
563 |
|
564 |
<p>
|
565 |
+
<a href="https://colab.research.google.com/github/asigalov61/Monster-Piano-Transformer/blob/main/Giant_Music_Transformer.ipynb">
|
566 |
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab">
|
567 |
</a> or
|
568 |
+
<a href="https://huggingface.co/spaces/asigalov61/Monster-Piano-Transformer?duplicate=true">
|
569 |
<img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-md.svg" alt="Duplicate in Hugging Face">
|
570 |
</a>
|
571 |
</p>
|