Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -187,6 +187,9 @@ def load_midi(input_midi):
|
|
| 187 |
|
| 188 |
@spaces.GPU
|
| 189 |
def Humanize_MIDI(input_midi,
|
|
|
|
|
|
|
|
|
|
| 190 |
model_temperature,
|
| 191 |
model_sampling_top_p
|
| 192 |
):
|
|
@@ -204,6 +207,9 @@ def Humanize_MIDI(input_midi,
|
|
| 204 |
fn = os.path.basename(input_midi)
|
| 205 |
fn1 = fn.split('.')[0]
|
| 206 |
print('Input MIDI file name:', fn)
|
|
|
|
|
|
|
|
|
|
| 207 |
print('Model temperature:', model_temperature)
|
| 208 |
print('Model top p:', model_sampling_top_p)
|
| 209 |
|
|
@@ -224,21 +230,18 @@ def Humanize_MIDI(input_midi,
|
|
| 224 |
|
| 225 |
#==================================================================
|
| 226 |
|
| 227 |
-
dur_vel_toks_num = len([t for t in score if 16767 < t < 18816])
|
| 228 |
|
| 229 |
-
print('Number of tokens to
|
| 230 |
|
| 231 |
#==================================================================
|
| 232 |
|
| 233 |
print('=' * 70)
|
| 234 |
print('Generating...')
|
| 235 |
|
| 236 |
-
|
| 237 |
-
inpaint_velocities = True
|
| 238 |
-
|
| 239 |
-
final_song = []
|
| 240 |
|
| 241 |
-
for t in tqdm.tqdm(score):
|
| 242 |
|
| 243 |
if t < 16767 or t > 18815:
|
| 244 |
final_song.append(t)
|
|
@@ -265,10 +268,10 @@ def Humanize_MIDI(input_midi,
|
|
| 265 |
gdur = ((y-16768) // 8)
|
| 266 |
gvel = (((y-16768) % 8)+1)
|
| 267 |
|
| 268 |
-
if
|
| 269 |
fdur = gdur
|
| 270 |
|
| 271 |
-
if
|
| 272 |
fvel = gvel
|
| 273 |
|
| 274 |
dur_vel_tok = ((8 * fdur) + fvel) + 16768
|
|
@@ -447,6 +450,9 @@ with gr.Blocks() as demo:
|
|
| 447 |
|
| 448 |
generate_btn.click(Humanize_MIDI,
|
| 449 |
[input_midi,
|
|
|
|
|
|
|
|
|
|
| 450 |
model_temperature,
|
| 451 |
model_sampling_top_p
|
| 452 |
],
|
|
@@ -460,6 +466,9 @@ with gr.Blocks() as demo:
|
|
| 460 |
[["Sharing The Night Together.kar", 0.9, 0.96]
|
| 461 |
],
|
| 462 |
[input_midi,
|
|
|
|
|
|
|
|
|
|
| 463 |
model_temperature,
|
| 464 |
model_sampling_top_p
|
| 465 |
],
|
|
|
|
| 187 |
|
| 188 |
@spaces.GPU
|
| 189 |
def Humanize_MIDI(input_midi,
|
| 190 |
+
num_prime_toks,
|
| 191 |
+
humanize_durations,
|
| 192 |
+
humanize_velocities,
|
| 193 |
model_temperature,
|
| 194 |
model_sampling_top_p
|
| 195 |
):
|
|
|
|
| 207 |
fn = os.path.basename(input_midi)
|
| 208 |
fn1 = fn.split('.')[0]
|
| 209 |
print('Input MIDI file name:', fn)
|
| 210 |
+
print('Number of prime tokens:', num_prime_toks)
|
| 211 |
+
print('Humanize durations:', humanize_durations)
|
| 212 |
+
print('Humanize velocities:', humanize_velocities)
|
| 213 |
print('Model temperature:', model_temperature)
|
| 214 |
print('Model top p:', model_sampling_top_p)
|
| 215 |
|
|
|
|
| 230 |
|
| 231 |
#==================================================================
|
| 232 |
|
| 233 |
+
dur_vel_toks_num = len([t for t in score[num_prime_toks:] if 16767 < t < 18816])
|
| 234 |
|
| 235 |
+
print('Number of tokens to humanize:', dur_vel_toks_num)
|
| 236 |
|
| 237 |
#==================================================================
|
| 238 |
|
| 239 |
print('=' * 70)
|
| 240 |
print('Generating...')
|
| 241 |
|
| 242 |
+
final_song = score[:num_prime_toks]
|
|
|
|
|
|
|
|
|
|
| 243 |
|
| 244 |
+
for t in tqdm.tqdm(score[:num_prime_toks]):
|
| 245 |
|
| 246 |
if t < 16767 or t > 18815:
|
| 247 |
final_song.append(t)
|
|
|
|
| 268 |
gdur = ((y-16768) // 8)
|
| 269 |
gvel = (((y-16768) % 8)+1)
|
| 270 |
|
| 271 |
+
if humanize_durations:
|
| 272 |
fdur = gdur
|
| 273 |
|
| 274 |
+
if humanize_velocities:
|
| 275 |
fvel = gvel
|
| 276 |
|
| 277 |
dur_vel_tok = ((8 * fdur) + fvel) + 16768
|
|
|
|
| 450 |
|
| 451 |
generate_btn.click(Humanize_MIDI,
|
| 452 |
[input_midi,
|
| 453 |
+
num_prime_toks,
|
| 454 |
+
humanize_durations,
|
| 455 |
+
humanize_velocities,
|
| 456 |
model_temperature,
|
| 457 |
model_sampling_top_p
|
| 458 |
],
|
|
|
|
| 466 |
[["Sharing The Night Together.kar", 0.9, 0.96]
|
| 467 |
],
|
| 468 |
[input_midi,
|
| 469 |
+
num_prime_toks,
|
| 470 |
+
humanize_durations,
|
| 471 |
+
humanize_velocities,
|
| 472 |
model_temperature,
|
| 473 |
model_sampling_top_p
|
| 474 |
],
|