Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -71,7 +71,7 @@ dtype = 'bfloat16'
|
|
| 71 |
ptdtype = {'bfloat16': torch.bfloat16, 'float16': torch.float16}[dtype]
|
| 72 |
ctx = torch.amp.autocast(device_type=device_type, dtype=ptdtype)
|
| 73 |
|
| 74 |
-
SEQ_LEN =
|
| 75 |
PAD_IDX = 18819
|
| 76 |
|
| 77 |
model = TransformerWrapper(num_tokens = PAD_IDX+1,
|
|
@@ -110,56 +110,79 @@ def load_midi(input_midi):
|
|
| 110 |
|
| 111 |
raw_score = TMIDIX.midi2single_track_ms_score(input_midi)
|
| 112 |
|
| 113 |
-
escore_notes = TMIDIX.advanced_score_processor(raw_score, return_enhanced_score_notes=True)
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
-
|
|
|
|
| 154 |
|
| 155 |
#==================================================================================
|
| 156 |
|
| 157 |
@spaces.GPU
|
| 158 |
-
def
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
):
|
| 163 |
|
| 164 |
#===============================================================================
|
| 165 |
|
|
@@ -174,7 +197,6 @@ def Generate_Chords_Textures(input_midi,
|
|
| 174 |
fn = os.path.basename(input_midi)
|
| 175 |
fn1 = fn.split('.')[0]
|
| 176 |
print('Input MIDI file name:', fn)
|
| 177 |
-
print('Prime with first note:', prime_with_first_note)
|
| 178 |
print('Model temperature:', model_temperature)
|
| 179 |
print('Model top p:', model_sampling_top_p)
|
| 180 |
|
|
@@ -182,145 +204,153 @@ def Generate_Chords_Textures(input_midi,
|
|
| 182 |
|
| 183 |
#==================================================================
|
| 184 |
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
print('Generating...')
|
| 206 |
-
|
| 207 |
-
if prime_with_first_note:
|
| 208 |
-
seq = [705] + chords[:128] + [706] + score[:4]
|
| 209 |
-
|
| 210 |
-
else:
|
| 211 |
-
seq = [705] + chords[:128] + [706]
|
| 212 |
-
|
| 213 |
-
x = torch.LongTensor(seq).to(device_type)
|
| 214 |
-
|
| 215 |
-
with ctx:
|
| 216 |
-
out = model.generate(x,
|
| 217 |
-
1024,
|
| 218 |
-
temperature=model_temperature,
|
| 219 |
-
filter_logits_fn=top_p,
|
| 220 |
-
filter_kwargs={'thres': model_sampling_top_p},
|
| 221 |
-
return_prime=True,
|
| 222 |
-
eos_token=707,
|
| 223 |
-
verbose=False)
|
| 224 |
-
|
| 225 |
-
if prime_with_first_note:
|
| 226 |
-
final_song = out.tolist()[len(seq)-4:]
|
| 227 |
-
|
| 228 |
-
else:
|
| 229 |
-
final_song = out.tolist()[len(seq):]
|
| 230 |
-
|
| 231 |
-
#==================================================================
|
| 232 |
-
|
| 233 |
-
ccount = -1
|
| 234 |
-
|
| 235 |
-
for i, f in enumerate(final_song):
|
| 236 |
-
|
| 237 |
-
if f > 384:
|
| 238 |
-
ccount += 1
|
| 239 |
|
| 240 |
-
|
| 241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
for m in final_song:
|
| 273 |
-
|
| 274 |
-
if 0 <= m < 128:
|
| 275 |
-
time += m * 32
|
| 276 |
-
|
| 277 |
-
elif 128 < m < 256:
|
| 278 |
-
dur = (m-128) * 32
|
| 279 |
-
|
| 280 |
-
elif 256 < m < 384:
|
| 281 |
-
pitch = (m-256)
|
| 282 |
-
|
| 283 |
-
song_f.append(['note', time, dur, 0, pitch, max(40, pitch), 0])
|
| 284 |
-
|
| 285 |
-
fn1 = "Orpheus-Bridge-Music-Transformer-Composition"
|
| 286 |
-
|
| 287 |
-
detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(song_f,
|
| 288 |
-
output_signature = 'Orpheus Bridge Music Transformer',
|
| 289 |
-
output_file_name = fn1,
|
| 290 |
-
track_name='Project Los Angeles',
|
| 291 |
-
list_of_MIDI_patches=patches
|
| 292 |
-
)
|
| 293 |
-
|
| 294 |
-
new_fn = fn1+'.mid'
|
| 295 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
sample_rate=16000,
|
| 300 |
-
volume_scale=10,
|
| 301 |
-
output_for_gradio=True
|
| 302 |
-
)
|
| 303 |
-
|
| 304 |
-
print('Done!')
|
| 305 |
-
print('=' * 70)
|
| 306 |
-
|
| 307 |
-
#========================================================
|
| 308 |
-
|
| 309 |
-
output_midi = str(new_fn)
|
| 310 |
-
output_audio = (16000, audio)
|
| 311 |
-
output_plot = TMIDIX.plot_ms_SONG(song_f, plot_title=output_midi, return_plt=True)
|
| 312 |
-
|
| 313 |
-
print('Output MIDI file name:', output_midi)
|
| 314 |
-
print('=' * 70)
|
| 315 |
|
| 316 |
-
|
|
|
|
|
|
|
|
|
|
| 317 |
|
| 318 |
-
|
| 319 |
-
print('Req end time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
| 320 |
-
print('-' * 70)
|
| 321 |
-
print('Req execution time:', (reqtime.time() - start_time), 'sec')
|
| 322 |
|
| 323 |
-
return
|
|
|
|
| 324 |
|
| 325 |
#==================================================================================
|
| 326 |
|
|
@@ -351,7 +381,7 @@ with gr.Blocks() as demo:
|
|
| 351 |
#==================================================================================
|
| 352 |
|
| 353 |
gr.Markdown("## Upload source MIDI or select a sample MIDI on the bottom of the page")
|
| 354 |
-
gr.Markdown("### PLEASE NOTE: The
|
| 355 |
|
| 356 |
input_midi = gr.File(label="Input MIDI",
|
| 357 |
file_types=[".midi", ".mid", ".kar"]
|
|
@@ -359,7 +389,6 @@ with gr.Blocks() as demo:
|
|
| 359 |
|
| 360 |
gr.Markdown("## Generation options")
|
| 361 |
|
| 362 |
-
prime_with_first_note = gr.Checkbox(value=True, label="Use the first note onset, duration and pitch to prime the model")
|
| 363 |
model_temperature = gr.Slider(0.1, 1, value=0.9, step=0.01, label="Model temperature")
|
| 364 |
model_sampling_top_p = gr.Slider(0.1, 0.99, value=0.96, step=0.01, label="Model sampling top p value")
|
| 365 |
|
|
@@ -372,9 +401,8 @@ with gr.Blocks() as demo:
|
|
| 372 |
output_plot = gr.Plot(label="MIDI score plot")
|
| 373 |
output_midi = gr.File(label="MIDI file", file_types=[".mid"])
|
| 374 |
|
| 375 |
-
generate_btn.click(
|
| 376 |
[input_midi,
|
| 377 |
-
prime_with_first_note,
|
| 378 |
model_temperature,
|
| 379 |
model_sampling_top_p
|
| 380 |
],
|
|
@@ -385,10 +413,9 @@ with gr.Blocks() as demo:
|
|
| 385 |
)
|
| 386 |
|
| 387 |
gr.Examples(
|
| 388 |
-
[["Sharing The Night Together.kar",
|
| 389 |
],
|
| 390 |
[input_midi,
|
| 391 |
-
prime_with_first_note,
|
| 392 |
model_temperature,
|
| 393 |
model_sampling_top_p
|
| 394 |
],
|
|
@@ -396,7 +423,7 @@ with gr.Blocks() as demo:
|
|
| 396 |
output_plot,
|
| 397 |
output_midi
|
| 398 |
],
|
| 399 |
-
|
| 400 |
)
|
| 401 |
|
| 402 |
#==================================================================================
|
|
|
|
| 71 |
ptdtype = {'bfloat16': torch.bfloat16, 'float16': torch.float16}[dtype]
|
| 72 |
ctx = torch.amp.autocast(device_type=device_type, dtype=ptdtype)
|
| 73 |
|
| 74 |
+
SEQ_LEN = 1668
|
| 75 |
PAD_IDX = 18819
|
| 76 |
|
| 77 |
model = TransformerWrapper(num_tokens = PAD_IDX+1,
|
|
|
|
| 110 |
|
| 111 |
raw_score = TMIDIX.midi2single_track_ms_score(input_midi)
|
| 112 |
|
| 113 |
+
escore_notes = TMIDIX.advanced_score_processor(raw_score, return_enhanced_score_notes=True, apply_sustain=True)
|
| 114 |
+
|
| 115 |
+
if escore_notes:
|
| 116 |
+
|
| 117 |
+
escore_notes = TMIDIX.augment_enhanced_score_notes(escore_notes[0], sort_drums_last=True)
|
| 118 |
+
|
| 119 |
+
dscore = TMIDIX.delta_score_notes(escore_notes)
|
| 120 |
+
|
| 121 |
+
dcscore = TMIDIX.chordify_score([d[1:] for d in dscore])
|
| 122 |
+
|
| 123 |
+
melody_chords = [18816]
|
| 124 |
+
|
| 125 |
+
#=======================================================
|
| 126 |
+
# MAIN PROCESSING CYCLE
|
| 127 |
+
#=======================================================
|
| 128 |
+
|
| 129 |
+
for i, c in enumerate(dcscore):
|
| 130 |
+
|
| 131 |
+
delta_time = c[0][0]
|
| 132 |
+
|
| 133 |
+
melody_chords.append(delta_time)
|
| 134 |
+
|
| 135 |
+
for e in c:
|
| 136 |
+
|
| 137 |
+
#=======================================================
|
| 138 |
+
|
| 139 |
+
# Durations
|
| 140 |
+
dur = max(1, min(255, e[1]))
|
| 141 |
+
|
| 142 |
+
# Patches
|
| 143 |
+
pat = max(0, min(128, e[5]))
|
| 144 |
+
|
| 145 |
+
# Pitches
|
| 146 |
+
ptc = max(1, min(127, e[3]))
|
| 147 |
+
|
| 148 |
+
# Velocities
|
| 149 |
+
# Calculating octo-velocity
|
| 150 |
+
|
| 151 |
+
vel = max(8, min(127, e[4]))
|
| 152 |
+
velocity = round(vel / 15)-1
|
| 153 |
+
|
| 154 |
+
#=======================================================
|
| 155 |
+
# FINAL NOTE SEQ
|
| 156 |
+
#=======================================================
|
| 157 |
+
|
| 158 |
+
# Writing final note
|
| 159 |
+
pat_ptc = (128 * pat) + ptc
|
| 160 |
+
dur_vel = (8 * dur) + velocity
|
| 161 |
+
|
| 162 |
+
melody_chords.extend([pat_ptc+256, dur_vel+16768]) # 18816
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
print('Done!')
|
| 166 |
+
print('=' * 70)
|
| 167 |
+
print('Score hss', len(melody_chords), 'tokens')
|
| 168 |
+
print('=' * 70)
|
| 169 |
+
|
| 170 |
+
if len(melody_chords) > SEQ_LEN:
|
| 171 |
+
return melody_chords
|
| 172 |
+
|
| 173 |
+
else:
|
| 174 |
+
return None
|
| 175 |
|
| 176 |
+
else:
|
| 177 |
+
return None
|
| 178 |
|
| 179 |
#==================================================================================
|
| 180 |
|
| 181 |
@spaces.GPU
|
| 182 |
+
def Generate_Music_Bridge(input_midi,
|
| 183 |
+
model_temperature,
|
| 184 |
+
model_sampling_top_p
|
| 185 |
+
):
|
|
|
|
| 186 |
|
| 187 |
#===============================================================================
|
| 188 |
|
|
|
|
| 197 |
fn = os.path.basename(input_midi)
|
| 198 |
fn1 = fn.split('.')[0]
|
| 199 |
print('Input MIDI file name:', fn)
|
|
|
|
| 200 |
print('Model temperature:', model_temperature)
|
| 201 |
print('Model top p:', model_sampling_top_p)
|
| 202 |
|
|
|
|
| 204 |
|
| 205 |
#==================================================================
|
| 206 |
|
| 207 |
+
if input_midi is not None:
|
| 208 |
+
|
| 209 |
+
print('Loading MIDI...')
|
| 210 |
+
|
| 211 |
+
score = load_midi(input_midi.name)
|
| 212 |
+
|
| 213 |
+
if score is not None:
|
| 214 |
+
print('Sample score tokens', score[:10])
|
| 215 |
+
|
| 216 |
+
#==================================================================
|
| 217 |
+
|
| 218 |
+
chords_len = 128
|
| 219 |
+
|
| 220 |
+
if len(chords) < 128:
|
| 221 |
+
chords_len = len(chords)
|
| 222 |
+
chords = chords * ((128 // chords_len)+1)
|
| 223 |
+
|
| 224 |
+
chords = chords[:128]
|
| 225 |
+
|
| 226 |
+
#==================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
|
| 228 |
+
print('=' * 70)
|
| 229 |
+
print('Generating...')
|
| 230 |
+
|
| 231 |
+
if prime_with_first_note:
|
| 232 |
+
seq = [705] + chords[:128] + [706] + score[:4]
|
| 233 |
+
|
| 234 |
+
else:
|
| 235 |
+
seq = [705] + chords[:128] + [706]
|
| 236 |
+
|
| 237 |
+
x = torch.LongTensor(seq).to(device_type)
|
| 238 |
|
| 239 |
+
with ctx:
|
| 240 |
+
out = model.generate(x,
|
| 241 |
+
1024,
|
| 242 |
+
temperature=model_temperature,
|
| 243 |
+
filter_logits_fn=top_p,
|
| 244 |
+
filter_kwargs={'thres': model_sampling_top_p},
|
| 245 |
+
return_prime=True,
|
| 246 |
+
eos_token=707,
|
| 247 |
+
verbose=False)
|
| 248 |
+
|
| 249 |
+
if prime_with_first_note:
|
| 250 |
+
final_song = out.tolist()[len(seq)-4:]
|
| 251 |
+
|
| 252 |
+
else:
|
| 253 |
+
final_song = out.tolist()[len(seq):]
|
| 254 |
+
|
| 255 |
+
#==================================================================
|
| 256 |
+
|
| 257 |
+
ccount = -1
|
| 258 |
+
|
| 259 |
+
for i, f in enumerate(final_song):
|
| 260 |
+
|
| 261 |
+
if f > 384:
|
| 262 |
+
ccount += 1
|
| 263 |
+
|
| 264 |
+
if ccount == chords_len:
|
| 265 |
+
break
|
| 266 |
+
|
| 267 |
+
final_song = final_song[:i]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
|
| 269 |
+
#==================================================================
|
| 270 |
+
|
| 271 |
+
print('=' * 70)
|
| 272 |
+
print('Done!')
|
| 273 |
+
print('=' * 70)
|
| 274 |
+
|
| 275 |
+
#===============================================================================
|
| 276 |
+
|
| 277 |
+
print('Rendering results...')
|
| 278 |
+
|
| 279 |
+
print('=' * 70)
|
| 280 |
+
print('Sample INTs', final_song[:15])
|
| 281 |
+
print('=' * 70)
|
| 282 |
+
|
| 283 |
+
song_f = []
|
| 284 |
+
|
| 285 |
+
if len(final_song) != 0:
|
| 286 |
+
|
| 287 |
+
time = 0
|
| 288 |
+
dur = 1
|
| 289 |
+
vel = 90
|
| 290 |
+
pitch = 60
|
| 291 |
+
channel = 0
|
| 292 |
+
patch = 0
|
| 293 |
+
|
| 294 |
+
patches = [0] * 16
|
| 295 |
+
|
| 296 |
+
for m in final_song:
|
| 297 |
+
|
| 298 |
+
if 0 <= m < 128:
|
| 299 |
+
time += m * 32
|
| 300 |
+
|
| 301 |
+
elif 128 < m < 256:
|
| 302 |
+
dur = (m-128) * 32
|
| 303 |
+
|
| 304 |
+
elif 256 < m < 384:
|
| 305 |
+
pitch = (m-256)
|
| 306 |
+
|
| 307 |
+
song_f.append(['note', time, dur, 0, pitch, max(40, pitch), 0])
|
| 308 |
+
|
| 309 |
+
fn1 = "Orpheus-Bridge-Music-Transformer-Composition"
|
| 310 |
+
|
| 311 |
+
detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(song_f,
|
| 312 |
+
output_signature = 'Orpheus Bridge Music Transformer',
|
| 313 |
+
output_file_name = fn1,
|
| 314 |
+
track_name='Project Los Angeles',
|
| 315 |
+
list_of_MIDI_patches=patches
|
| 316 |
+
)
|
| 317 |
+
|
| 318 |
+
new_fn = fn1+'.mid'
|
| 319 |
+
|
| 320 |
+
|
| 321 |
+
audio = midi_to_colab_audio(new_fn,
|
| 322 |
+
soundfont_path=SOUDFONT_PATH,
|
| 323 |
+
sample_rate=16000,
|
| 324 |
+
volume_scale=10,
|
| 325 |
+
output_for_gradio=True
|
| 326 |
+
)
|
| 327 |
+
|
| 328 |
+
print('Done!')
|
| 329 |
+
print('=' * 70)
|
| 330 |
+
|
| 331 |
+
#========================================================
|
| 332 |
+
|
| 333 |
+
output_midi = str(new_fn)
|
| 334 |
+
output_audio = (16000, audio)
|
| 335 |
+
output_plot = TMIDIX.plot_ms_SONG(song_f, plot_title=output_midi, return_plt=True)
|
| 336 |
+
|
| 337 |
+
print('Output MIDI file name:', output_midi)
|
| 338 |
+
print('=' * 70)
|
| 339 |
+
|
| 340 |
+
#========================================================
|
| 341 |
|
| 342 |
+
else:
|
| 343 |
+
return None, None, None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
|
| 345 |
+
print('-' * 70)
|
| 346 |
+
print('Req end time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
| 347 |
+
print('-' * 70)
|
| 348 |
+
print('Req execution time:', (reqtime.time() - start_time), 'sec')
|
| 349 |
|
| 350 |
+
return output_audio, output_plot, output_midi
|
|
|
|
|
|
|
|
|
|
| 351 |
|
| 352 |
+
return
|
| 353 |
+
None, None, None
|
| 354 |
|
| 355 |
#==================================================================================
|
| 356 |
|
|
|
|
| 381 |
#==================================================================================
|
| 382 |
|
| 383 |
gr.Markdown("## Upload source MIDI or select a sample MIDI on the bottom of the page")
|
| 384 |
+
gr.Markdown("### PLEASE NOTE: The MIDI file MUST HAVE at least 800 MIDI pitches for the demo to work properly!")
|
| 385 |
|
| 386 |
input_midi = gr.File(label="Input MIDI",
|
| 387 |
file_types=[".midi", ".mid", ".kar"]
|
|
|
|
| 389 |
|
| 390 |
gr.Markdown("## Generation options")
|
| 391 |
|
|
|
|
| 392 |
model_temperature = gr.Slider(0.1, 1, value=0.9, step=0.01, label="Model temperature")
|
| 393 |
model_sampling_top_p = gr.Slider(0.1, 0.99, value=0.96, step=0.01, label="Model sampling top p value")
|
| 394 |
|
|
|
|
| 401 |
output_plot = gr.Plot(label="MIDI score plot")
|
| 402 |
output_midi = gr.File(label="MIDI file", file_types=[".mid"])
|
| 403 |
|
| 404 |
+
generate_btn.click(Generate_Music_Bridge,
|
| 405 |
[input_midi,
|
|
|
|
| 406 |
model_temperature,
|
| 407 |
model_sampling_top_p
|
| 408 |
],
|
|
|
|
| 413 |
)
|
| 414 |
|
| 415 |
gr.Examples(
|
| 416 |
+
[["Sharing The Night Together.kar", 0.9, 0.96]
|
| 417 |
],
|
| 418 |
[input_midi,
|
|
|
|
| 419 |
model_temperature,
|
| 420 |
model_sampling_top_p
|
| 421 |
],
|
|
|
|
| 423 |
output_plot,
|
| 424 |
output_midi
|
| 425 |
],
|
| 426 |
+
Generate_Music_Bridge
|
| 427 |
)
|
| 428 |
|
| 429 |
#==================================================================================
|