Fix model registration + add long-form generation support
- Fix critical bug: register_all_adapters() now called in main.py - Add generate_long() method to MusicGen adapter for continuation-based extended tracks (up to 5 minutes) - Add long-form checkbox in UI that unlocks duration slider to 300s - Update GenerationService to route to generate_long when duration > 30s - Update BatchProcessor to support long_form parameter 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -86,6 +86,13 @@ def create_musicgen_tab(
|
||||
# Parameters
|
||||
gr.Markdown("### Parameters")
|
||||
|
||||
# Long-form generation checkbox
|
||||
long_form_checkbox = gr.Checkbox(
|
||||
label="Long-form generation",
|
||||
value=False,
|
||||
info="Enable for tracks > 30s (uses continuation, takes longer)",
|
||||
)
|
||||
|
||||
duration_slider = gr.Slider(
|
||||
minimum=1,
|
||||
maximum=30,
|
||||
@@ -94,6 +101,13 @@ def create_musicgen_tab(
|
||||
label="Duration (seconds)",
|
||||
)
|
||||
|
||||
# Info text for long-form mode
|
||||
long_form_info = gr.Markdown(
|
||||
value="*Long-form mode uses continuation to generate extended tracks. "
|
||||
"Generation time increases significantly for longer durations.*",
|
||||
visible=False,
|
||||
)
|
||||
|
||||
with gr.Accordion("Advanced Parameters", open=False):
|
||||
with gr.Row():
|
||||
temperature_slider = gr.Slider(
|
||||
@@ -177,6 +191,25 @@ def create_musicgen_tab(
|
||||
outputs=[melody_section],
|
||||
)
|
||||
|
||||
# Long-form checkbox - update duration slider max
|
||||
def on_long_form_change(long_form: bool):
|
||||
if long_form:
|
||||
return (
|
||||
gr.update(maximum=300, label="Duration (seconds) - up to 5 min"),
|
||||
gr.update(visible=True),
|
||||
)
|
||||
else:
|
||||
return (
|
||||
gr.update(maximum=30, label="Duration (seconds)"),
|
||||
gr.update(visible=False),
|
||||
)
|
||||
|
||||
long_form_checkbox.change(
|
||||
fn=on_long_form_change,
|
||||
inputs=[long_form_checkbox],
|
||||
outputs=[duration_slider, long_form_info],
|
||||
)
|
||||
|
||||
# Prompt suggestions
|
||||
for btn, suggestion in suggestion_btns:
|
||||
btn.click(
|
||||
@@ -186,7 +219,7 @@ def create_musicgen_tab(
|
||||
|
||||
# Generate
|
||||
async def do_generate(
|
||||
prompt, variant, duration, temperature, cfg_coef, top_k, top_p, seed, melody
|
||||
prompt, variant, duration, temperature, cfg_coef, top_k, top_p, seed, melody, long_form
|
||||
):
|
||||
if not prompt:
|
||||
yield (
|
||||
@@ -199,9 +232,14 @@ def create_musicgen_tab(
|
||||
)
|
||||
return
|
||||
|
||||
# Generate status message
|
||||
status_msg = "🔄 Generating..."
|
||||
if long_form and duration > 30:
|
||||
status_msg = f"🔄 Long-form generation ({duration}s, may take several minutes)..."
|
||||
|
||||
# Update status
|
||||
yield (
|
||||
gr.update(value="🔄 Generating..."),
|
||||
gr.update(value=status_msg),
|
||||
gr.update(visible=True, value=0),
|
||||
gr.update(),
|
||||
gr.update(),
|
||||
@@ -225,6 +263,7 @@ def create_musicgen_tab(
|
||||
cfg_coef=cfg_coef,
|
||||
seed=int(seed) if seed else None,
|
||||
conditioning=conditioning,
|
||||
long_form=long_form,
|
||||
)
|
||||
|
||||
yield (
|
||||
@@ -258,6 +297,7 @@ def create_musicgen_tab(
|
||||
top_p_slider,
|
||||
seed_input,
|
||||
melody_input,
|
||||
long_form_checkbox,
|
||||
],
|
||||
outputs=[
|
||||
output["status"],
|
||||
@@ -270,7 +310,7 @@ def create_musicgen_tab(
|
||||
)
|
||||
|
||||
# Add to queue
|
||||
def do_add_queue(prompt, variant, duration, temperature, cfg_coef, top_k, top_p, seed, melody):
|
||||
def do_add_queue(prompt, variant, duration, temperature, cfg_coef, top_k, top_p, seed, melody, long_form):
|
||||
if not prompt:
|
||||
return "Please enter a prompt"
|
||||
|
||||
@@ -289,6 +329,7 @@ def create_musicgen_tab(
|
||||
cfg_coef=cfg_coef,
|
||||
seed=int(seed) if seed else None,
|
||||
conditioning=conditioning,
|
||||
long_form=long_form,
|
||||
)
|
||||
|
||||
return f"✅ Added to queue: {job.id}"
|
||||
@@ -305,6 +346,7 @@ def create_musicgen_tab(
|
||||
top_p_slider,
|
||||
seed_input,
|
||||
melody_input,
|
||||
long_form_checkbox,
|
||||
],
|
||||
outputs=[output["status"]],
|
||||
)
|
||||
@@ -314,6 +356,7 @@ def create_musicgen_tab(
|
||||
"variant": variant_dropdown,
|
||||
"prompt": prompt_input,
|
||||
"melody": melody_input,
|
||||
"long_form": long_form_checkbox,
|
||||
"duration": duration_slider,
|
||||
"temperature": temperature_slider,
|
||||
"cfg_coef": cfg_slider,
|
||||
|
||||
Reference in New Issue
Block a user