Spaces:
Running
on
Zero
Running
on
Zero
asigalov61
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
#==================================================================================
|
|
|
|
|
2 |
|
3 |
print('=' * 70)
|
4 |
print('Loading core Giant Music Transformer modules...')
|
@@ -21,9 +23,6 @@ torch.backends.cuda.enable_math_sdp(True)
|
|
21 |
torch.backends.cuda.enable_flash_sdp(True)
|
22 |
torch.backends.cuda.enable_cudnn_sdp(True)
|
23 |
|
24 |
-
os.chdir('/home/ubuntu/Giant-Music-Transformer/')
|
25 |
-
print("Current working directory: ", os.getcwd())
|
26 |
-
sys.path.append(os.getcwd())
|
27 |
import TMIDIX
|
28 |
|
29 |
from midi_to_colab_audio import midi_to_colab_audio
|
@@ -32,7 +31,6 @@ from x_transformer_1_23_2 import *
|
|
32 |
|
33 |
import random
|
34 |
|
35 |
-
os.chdir('/home/ubuntu/')
|
36 |
print('=' * 70)
|
37 |
print('Loading aux Giant Music Transformer modules...')
|
38 |
|
@@ -77,7 +75,7 @@ model = AutoregressiveWrapper(model, ignore_index=PAD_IDX, pad_value=PAD_IDX)
|
|
77 |
print('=' * 70)
|
78 |
print('Loading model checkpoint...')
|
79 |
|
80 |
-
model_path = '
|
81 |
|
82 |
model.load_state_dict(torch.load(model_path))
|
83 |
|
@@ -93,7 +91,7 @@ print('=' * 70)
|
|
93 |
|
94 |
#==================================================================================
|
95 |
|
96 |
-
SOUDFONT_PATH = '
|
97 |
|
98 |
NUM_OUT_BATCHES = 8
|
99 |
|
@@ -234,10 +232,10 @@ def save_midi(tokens, batch_number=None):
|
|
234 |
patches = [0 if x==-1 else x for x in patches]
|
235 |
|
236 |
if batch_number == None:
|
237 |
-
fname = '
|
238 |
|
239 |
else:
|
240 |
-
fname = '
|
241 |
|
242 |
data = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(song_f,
|
243 |
output_signature = 'Giant Music Transformer',
|
@@ -338,7 +336,7 @@ def generate_callback(input_midi,
|
|
338 |
midi_plot = TMIDIX.plot_ms_SONG(midi_score, plot_title='Batch # ' + str(i), return_plt=True)
|
339 |
|
340 |
# File name
|
341 |
-
fname = '
|
342 |
|
343 |
# Save audio to a temporary file
|
344 |
midi_audio = midi_to_colab_audio(fname + '.mid',
|
|
|
1 |
#==================================================================================
|
2 |
+
# https://huggingface.co/spaces/asigalov61/Giant-Music-Transformer
|
3 |
+
#==================================================================================
|
4 |
|
5 |
print('=' * 70)
|
6 |
print('Loading core Giant Music Transformer modules...')
|
|
|
23 |
torch.backends.cuda.enable_flash_sdp(True)
|
24 |
torch.backends.cuda.enable_cudnn_sdp(True)
|
25 |
|
|
|
|
|
|
|
26 |
import TMIDIX
|
27 |
|
28 |
from midi_to_colab_audio import midi_to_colab_audio
|
|
|
31 |
|
32 |
import random
|
33 |
|
|
|
34 |
print('=' * 70)
|
35 |
print('Loading aux Giant Music Transformer modules...')
|
36 |
|
|
|
75 |
print('=' * 70)
|
76 |
print('Loading model checkpoint...')
|
77 |
|
78 |
+
model_path = 'Giant-Music-Transformer/Models/Medium/Giant_Music_Transformer_Medium_Trained_Model_10446_steps_0.7202_loss_0.8233_acc.pth'
|
79 |
|
80 |
model.load_state_dict(torch.load(model_path))
|
81 |
|
|
|
91 |
|
92 |
#==================================================================================
|
93 |
|
94 |
+
SOUDFONT_PATH = 'SGM-v2.01-YamahaGrand-Guit-Bass-v2.7'
|
95 |
|
96 |
NUM_OUT_BATCHES = 8
|
97 |
|
|
|
232 |
patches = [0 if x==-1 else x for x in patches]
|
233 |
|
234 |
if batch_number == None:
|
235 |
+
fname = 'Giant-Music-Transformer-Music-Composition'
|
236 |
|
237 |
else:
|
238 |
+
fname = 'Giant-Music-Transformer-Music-Composition_'+str(batch_number)
|
239 |
|
240 |
data = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(song_f,
|
241 |
output_signature = 'Giant Music Transformer',
|
|
|
336 |
midi_plot = TMIDIX.plot_ms_SONG(midi_score, plot_title='Batch # ' + str(i), return_plt=True)
|
337 |
|
338 |
# File name
|
339 |
+
fname = 'Giant-Music-Transformer-Music-Composition_'+str(i)
|
340 |
|
341 |
# Save audio to a temporary file
|
342 |
midi_audio = midi_to_colab_audio(fname + '.mid',
|