Spaces:
Runtime error
Runtime error
New Example settings, style update
Browse files- app.py +33 -14
- assets/vermilion.svg +0 -0
- style_20250331.css +7 -7
app.py
CHANGED
|
@@ -134,18 +134,22 @@ def git_tag():
|
|
| 134 |
except Exception:
|
| 135 |
return "<none>"
|
| 136 |
|
| 137 |
-
def load_melody_filepath(melody_filepath, title, assigned_model):
|
| 138 |
# get melody filename
|
| 139 |
#$Union[str, os.PathLike]
|
| 140 |
symbols = ['_', '.', '-']
|
| 141 |
if (melody_filepath is None) or (melody_filepath == ""):
|
| 142 |
-
return title, gr.update(maximum=0, value=0) , gr.update(value="medium", interactive=True)
|
| 143 |
|
| 144 |
if (title is None) or ("MusicGen" in title) or (title == ""):
|
| 145 |
melody_name, melody_extension = get_filename_from_filepath(melody_filepath)
|
| 146 |
# fix melody name for symbols
|
| 147 |
for symbol in symbols:
|
| 148 |
melody_name = melody_name.replace(symbol, ' ').title()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
else:
|
| 150 |
melody_name = title
|
| 151 |
|
|
@@ -162,7 +166,7 @@ def load_melody_filepath(melody_filepath, title, assigned_model):
|
|
| 162 |
print(f"Melody length: {len(melody_data)}, Melody segments: {total_melodys}\n")
|
| 163 |
MAX_PROMPT_INDEX = total_melodys
|
| 164 |
|
| 165 |
-
return gr.update(value=melody_name), gr.update(maximum=MAX_PROMPT_INDEX, value=0), gr.update(value=assigned_model, interactive=True)
|
| 166 |
|
| 167 |
def predict(model, text, melody_filepath, duration, dimension, topk, topp, temperature, cfg_coef, background, title, settings_font, settings_font_color, seed, overlap=1, prompt_index = 0, include_title = True, include_settings = True, harmony_only = False, profile = gr.OAuthProfile, progress=gr.Progress(track_tqdm=True)):
|
| 168 |
global MODEL, INTERRUPTED, INTERRUPTING, MOVE_TO_CPU
|
|
@@ -445,8 +449,8 @@ def ui(**kwargs):
|
|
| 445 |
with gr.Row():
|
| 446 |
with gr.Column():
|
| 447 |
with gr.Row():
|
| 448 |
-
text = gr.Text(label="Describe your music", interactive=True, value="4/4 100bpm 320kbps 48khz, Industrial/Electronic Soundtrack, Dark, Intense, Sci-Fi")
|
| 449 |
-
with gr.Column():
|
| 450 |
duration = gr.Slider(minimum=1, maximum=720, value=10, label="Duration (s)", interactive=True)
|
| 451 |
model = gr.Radio(["melody", "medium", "small", "large", "melody-large", "stereo-small", "stereo-medium", "stereo-large", "stereo-melody", "stereo-melody-large"], label="AI Model", value="medium", interactive=True)
|
| 452 |
with gr.Row():
|
|
@@ -456,7 +460,7 @@ def ui(**kwargs):
|
|
| 456 |
with gr.Row():
|
| 457 |
with gr.Column():
|
| 458 |
radio = gr.Radio(["file", "mic"], value="file", label="Condition on a melody (optional) File or Mic")
|
| 459 |
-
melody_filepath = gr.Audio(sources=["upload"], type="filepath", label="Melody Condition (optional)", interactive=True, elem_id="melody-input")
|
| 460 |
with gr.Column():
|
| 461 |
harmony_only = gr.Radio(label="Use Harmony Only",choices=["No", "Yes"], value="No", interactive=True, info="Remove Drums?")
|
| 462 |
prompt_index = gr.Slider(label="Melody Condition Sample Segment", minimum=-1, maximum=MAX_PROMPT_INDEX, step=1, value=0, interactive=True, info="Which 30 second segment to condition with, - 1 condition each segment independantly")
|
|
@@ -486,10 +490,10 @@ def ui(**kwargs):
|
|
| 486 |
with gr.Column() as c:
|
| 487 |
output = gr.Video(label="Generated Music")
|
| 488 |
wave_file = gr.File(label=".wav file", elem_id="output_wavefile", interactive=True)
|
| 489 |
-
seed_used = gr.Number(label='Seed used', value=-1, interactive=False)
|
| 490 |
|
| 491 |
radio.change(toggle_audio_src, radio, [melody_filepath], queue=False, show_progress=False)
|
| 492 |
-
melody_filepath.change(load_melody_filepath, inputs=[melody_filepath, title, model], outputs=[title, prompt_index , model], api_name="melody_filepath_change", queue=False)
|
| 493 |
reuse_seed.click(fn=lambda x: x, inputs=[seed_used], outputs=[seed], queue=False, api_name="reuse_seed")
|
| 494 |
|
| 495 |
gr.Examples(
|
|
@@ -498,34 +502,49 @@ def ui(**kwargs):
|
|
| 498 |
"4/4 120bpm 320kbps 48khz, An 80s driving pop song with heavy drums and synth pads in the background",
|
| 499 |
"./assets/bach.mp3",
|
| 500 |
"melody",
|
| 501 |
-
"80s Pop Synth"
|
|
|
|
|
|
|
|
|
|
| 502 |
],
|
| 503 |
[
|
| 504 |
"4/4 120bpm 320kbps 48khz, A cheerful country song with acoustic guitars",
|
| 505 |
"./assets/bolero_ravel.mp3",
|
| 506 |
"stereo-melody-large",
|
| 507 |
-
"Country Guitar"
|
|
|
|
|
|
|
|
|
|
| 508 |
],
|
| 509 |
[
|
| 510 |
"4/4 120bpm 320kbps 48khz, 90s rock song with electric guitar and heavy drums",
|
| 511 |
None,
|
| 512 |
"stereo-medium",
|
| 513 |
-
"90s Rock Guitar"
|
|
|
|
|
|
|
|
|
|
| 514 |
],
|
| 515 |
[
|
| 516 |
"4/4 120bpm 320kbps 48khz, a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions",
|
| 517 |
"./assets/bach.mp3",
|
| 518 |
"melody-large",
|
| 519 |
-
"EDM my Bach"
|
|
|
|
|
|
|
|
|
|
| 520 |
],
|
| 521 |
[
|
| 522 |
"4/4 320kbps 48khz, lofi slow bpm electro chill with organic samples",
|
| 523 |
None,
|
| 524 |
"medium",
|
| 525 |
-
"LoFi Chill"
|
|
|
|
|
|
|
|
|
|
| 526 |
],
|
| 527 |
],
|
| 528 |
-
inputs=[text, melody_filepath, model, title],
|
| 529 |
outputs=[output]
|
| 530 |
)
|
| 531 |
|
|
|
|
| 134 |
except Exception:
|
| 135 |
return "<none>"
|
| 136 |
|
| 137 |
+
def load_melody_filepath(melody_filepath, title, assigned_model,topp, temperature, cfg_coef):
|
| 138 |
# get melody filename
|
| 139 |
#$Union[str, os.PathLike]
|
| 140 |
symbols = ['_', '.', '-']
|
| 141 |
if (melody_filepath is None) or (melody_filepath == ""):
|
| 142 |
+
return title, gr.update(maximum=0, value=0) , gr.update(value="medium", interactive=True), gr.update(value=topp), gr.update(value=temperature), gr.update(value=cfg_coef)
|
| 143 |
|
| 144 |
if (title is None) or ("MusicGen" in title) or (title == ""):
|
| 145 |
melody_name, melody_extension = get_filename_from_filepath(melody_filepath)
|
| 146 |
# fix melody name for symbols
|
| 147 |
for symbol in symbols:
|
| 148 |
melody_name = melody_name.replace(symbol, ' ').title()
|
| 149 |
+
#additonal melody setting updates
|
| 150 |
+
topp = 500
|
| 151 |
+
temperature = 0.5
|
| 152 |
+
cfg_coef = 3.0
|
| 153 |
else:
|
| 154 |
melody_name = title
|
| 155 |
|
|
|
|
| 166 |
print(f"Melody length: {len(melody_data)}, Melody segments: {total_melodys}\n")
|
| 167 |
MAX_PROMPT_INDEX = total_melodys
|
| 168 |
|
| 169 |
+
return gr.update(value=melody_name), gr.update(maximum=MAX_PROMPT_INDEX, value=0), gr.update(value=assigned_model, interactive=True), gr.update(value=topp), gr.update(value=temperature), gr.update(value=cfg_coef)
|
| 170 |
|
| 171 |
def predict(model, text, melody_filepath, duration, dimension, topk, topp, temperature, cfg_coef, background, title, settings_font, settings_font_color, seed, overlap=1, prompt_index = 0, include_title = True, include_settings = True, harmony_only = False, profile = gr.OAuthProfile, progress=gr.Progress(track_tqdm=True)):
|
| 172 |
global MODEL, INTERRUPTED, INTERRUPTING, MOVE_TO_CPU
|
|
|
|
| 449 |
with gr.Row():
|
| 450 |
with gr.Column():
|
| 451 |
with gr.Row():
|
| 452 |
+
text = gr.Text(label="Describe your music", interactive=True, value="4/4 100bpm 320kbps 48khz, Industrial/Electronic Soundtrack, Dark, Intense, Sci-Fi, soft fade-in, soft fade-out")
|
| 453 |
+
with gr.Column():
|
| 454 |
duration = gr.Slider(minimum=1, maximum=720, value=10, label="Duration (s)", interactive=True)
|
| 455 |
model = gr.Radio(["melody", "medium", "small", "large", "melody-large", "stereo-small", "stereo-medium", "stereo-large", "stereo-melody", "stereo-melody-large"], label="AI Model", value="medium", interactive=True)
|
| 456 |
with gr.Row():
|
|
|
|
| 460 |
with gr.Row():
|
| 461 |
with gr.Column():
|
| 462 |
radio = gr.Radio(["file", "mic"], value="file", label="Condition on a melody (optional) File or Mic")
|
| 463 |
+
melody_filepath = gr.Audio(sources=["upload"], type="filepath", label="Melody Condition (optional)", interactive=True, elem_id="melody-input")
|
| 464 |
with gr.Column():
|
| 465 |
harmony_only = gr.Radio(label="Use Harmony Only",choices=["No", "Yes"], value="No", interactive=True, info="Remove Drums?")
|
| 466 |
prompt_index = gr.Slider(label="Melody Condition Sample Segment", minimum=-1, maximum=MAX_PROMPT_INDEX, step=1, value=0, interactive=True, info="Which 30 second segment to condition with, - 1 condition each segment independantly")
|
|
|
|
| 490 |
with gr.Column() as c:
|
| 491 |
output = gr.Video(label="Generated Music")
|
| 492 |
wave_file = gr.File(label=".wav file", elem_id="output_wavefile", interactive=True)
|
| 493 |
+
seed_used = gr.Number(label='Seed used', value=-1, interactive=False)
|
| 494 |
|
| 495 |
radio.change(toggle_audio_src, radio, [melody_filepath], queue=False, show_progress=False)
|
| 496 |
+
melody_filepath.change(load_melody_filepath, inputs=[melody_filepath, title, model,topp, temperature, cfg_coef], outputs=[title, prompt_index , model, topp, temperature, cfg_coef], api_name="melody_filepath_change", queue=False)
|
| 497 |
reuse_seed.click(fn=lambda x: x, inputs=[seed_used], outputs=[seed], queue=False, api_name="reuse_seed")
|
| 498 |
|
| 499 |
gr.Examples(
|
|
|
|
| 502 |
"4/4 120bpm 320kbps 48khz, An 80s driving pop song with heavy drums and synth pads in the background",
|
| 503 |
"./assets/bach.mp3",
|
| 504 |
"melody",
|
| 505 |
+
"80s Pop Synth",
|
| 506 |
+
950,
|
| 507 |
+
0,6,
|
| 508 |
+
5.0
|
| 509 |
],
|
| 510 |
[
|
| 511 |
"4/4 120bpm 320kbps 48khz, A cheerful country song with acoustic guitars",
|
| 512 |
"./assets/bolero_ravel.mp3",
|
| 513 |
"stereo-melody-large",
|
| 514 |
+
"Country Guitar",
|
| 515 |
+
750,
|
| 516 |
+
0,7,
|
| 517 |
+
4.75
|
| 518 |
],
|
| 519 |
[
|
| 520 |
"4/4 120bpm 320kbps 48khz, 90s rock song with electric guitar and heavy drums",
|
| 521 |
None,
|
| 522 |
"stereo-medium",
|
| 523 |
+
"90s Rock Guitar",
|
| 524 |
+
1150,
|
| 525 |
+
0,7,
|
| 526 |
+
4.5
|
| 527 |
],
|
| 528 |
[
|
| 529 |
"4/4 120bpm 320kbps 48khz, a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions",
|
| 530 |
"./assets/bach.mp3",
|
| 531 |
"melody-large",
|
| 532 |
+
"EDM my Bach",
|
| 533 |
+
500,
|
| 534 |
+
0,7,
|
| 535 |
+
3.5
|
| 536 |
],
|
| 537 |
[
|
| 538 |
"4/4 320kbps 48khz, lofi slow bpm electro chill with organic samples",
|
| 539 |
None,
|
| 540 |
"medium",
|
| 541 |
+
"LoFi Chill",
|
| 542 |
+
1150,
|
| 543 |
+
0,7,
|
| 544 |
+
8.5
|
| 545 |
],
|
| 546 |
],
|
| 547 |
+
inputs=[text, melody_filepath, model, title, topp, temperature, cfg_coef],
|
| 548 |
outputs=[output]
|
| 549 |
)
|
| 550 |
|
assets/vermilion.svg
ADDED
|
|
style_20250331.css
CHANGED
|
@@ -114,12 +114,12 @@ a {
|
|
| 114 |
top: 0;
|
| 115 |
width: 100%;
|
| 116 |
height: 100%;
|
| 117 |
-
opacity: 0.
|
| 118 |
-
background-image: url('gradio_api/file=./assets/
|
| 119 |
background-repeat: no-repeat;
|
| 120 |
-
background-position: 50%
|
| 121 |
/*background-color: rgba(0,0,0,0.5);*/
|
| 122 |
-
background-size:
|
| 123 |
overflow: hidden;
|
| 124 |
}
|
| 125 |
|
|
@@ -130,11 +130,11 @@ a {
|
|
| 130 |
left: -60%; /* Start off-screen */
|
| 131 |
width: 100%;
|
| 132 |
height: calc(100% + 150px);
|
| 133 |
-
background:
|
| 134 |
animation: 15s infinite shine;
|
| 135 |
-
animation: shine
|
| 136 |
opacity: 0.35;
|
| 137 |
-
z-index:2;
|
| 138 |
}
|
| 139 |
|
| 140 |
#component-0, #component-1 {
|
|
|
|
| 114 |
top: 0;
|
| 115 |
width: 100%;
|
| 116 |
height: 100%;
|
| 117 |
+
opacity: 0.4;
|
| 118 |
+
background-image: url('gradio_api/file=./assets/vermilion.svg');
|
| 119 |
background-repeat: no-repeat;
|
| 120 |
+
background-position: 50% 50%;
|
| 121 |
/*background-color: rgba(0,0,0,0.5);*/
|
| 122 |
+
background-size: 80vh;
|
| 123 |
overflow: hidden;
|
| 124 |
}
|
| 125 |
|
|
|
|
| 130 |
left: -60%; /* Start off-screen */
|
| 131 |
width: 100%;
|
| 132 |
height: calc(100% + 150px);
|
| 133 |
+
background: linear-gradient(to bottom right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0) 45%, rgba(255, 255, 255, 0.5) 48%, rgba(255, 255, 255, 0.8) 50%, rgba(255, 255, 255, 0.5) 52%, rgba(255, 255, 255, 0) 57%, rgba(255, 255, 255, 0) 100%);
|
| 134 |
animation: 15s infinite shine;
|
| 135 |
+
animation: shine 15s infinite;
|
| 136 |
opacity: 0.35;
|
| 137 |
+
z-index: 2;
|
| 138 |
}
|
| 139 |
|
| 140 |
#component-0, #component-1 {
|