thecollabagepatch commited on
Commit
7096e70
Β·
1 Parent(s): a71591f

fixing melodyflow

Browse files
Files changed (1) hide show
  1. app.py +19 -7
app.py CHANGED
@@ -152,20 +152,27 @@ def transform_with_melodyflow_api(audio_path, variation, custom_prompt="", solve
152
  # Determine the prompt to use
153
  if custom_prompt.strip():
154
  prompt_text = custom_prompt.strip()
155
- status_msg = f"βœ… Transformed with custom prompt: '{prompt_text}' (flowstep: {flowstep})"
156
  else:
157
  prompt_text = VARIATION_PROMPTS.get(variation, f"transform this audio to {variation} style")
158
- status_msg = f"βœ… Transformed with {variation} style (flowstep: {flowstep})"
159
 
160
- # Set steps based on solver (from your original logic)
161
- steps = 64 if solver == "midpoint" else 128
 
 
 
 
 
 
 
162
 
163
- # Call the MelodyFlow API
164
  result = client.predict(
165
  model="facebook/melodyflow-t24-30secs",
166
  text=prompt_text,
167
  solver=solver,
168
- steps=steps,
169
  target_flowstep=flowstep, # This is the key parameter!
170
  regularize=solver == "euler", # Regularize for euler, not for midpoint
171
  regularization_strength=0.2,
@@ -209,6 +216,10 @@ with gr.Blocks() as iface:
209
  4. **Repeat** the cycle to create infinite musical journeys!
210
 
211
  The models run with different PyTorch versions, so we use the Facebook MelodyFlow space via API.
 
 
 
 
212
  """)
213
 
214
  # ========== STEP 1: GENERATE ==========
@@ -249,7 +260,8 @@ with gr.Blocks() as iface:
249
  transform_solver = gr.Dropdown(
250
  label="Solver",
251
  choices=["euler", "midpoint"],
252
- value="euler"
 
253
  )
254
  transform_flowstep = gr.Slider(
255
  label="Transform Intensity (Flowstep)",
 
152
  # Determine the prompt to use
153
  if custom_prompt.strip():
154
  prompt_text = custom_prompt.strip()
155
+ status_msg = f"βœ… Transformed with custom prompt: '{prompt_text}' (flowstep: {flowstep}, {effective_steps} steps)"
156
  else:
157
  prompt_text = VARIATION_PROMPTS.get(variation, f"transform this audio to {variation} style")
158
+ status_msg = f"βœ… Transformed with {variation} style (flowstep: {flowstep}, {effective_steps} steps)"
159
 
160
+ # Set steps based on solver and the fact we're doing editing
161
+ # Facebook's space automatically reduces steps for editing:
162
+ # EULER: divides by 5, MIDPOINT: divides by 2
163
+ if solver == "midpoint":
164
+ base_steps = 128
165
+ effective_steps = base_steps // 2 # 64 effective steps
166
+ else: # euler
167
+ base_steps = 125
168
+ effective_steps = base_steps // 5 # 25 effective steps
169
 
170
+ # Call the MelodyFlow API with the base steps (it will auto-reduce)
171
  result = client.predict(
172
  model="facebook/melodyflow-t24-30secs",
173
  text=prompt_text,
174
  solver=solver,
175
+ steps=base_steps, # Will be auto-reduced to effective_steps by the space
176
  target_flowstep=flowstep, # This is the key parameter!
177
  regularize=solver == "euler", # Regularize for euler, not for midpoint
178
  regularization_strength=0.2,
 
216
  4. **Repeat** the cycle to create infinite musical journeys!
217
 
218
  The models run with different PyTorch versions, so we use the Facebook MelodyFlow space via API.
219
+
220
+ **Performance Note**: For audio transformation, MelodyFlow automatically uses fewer steps than generation:
221
+ - EULER solver: 25 effective steps (fast, good quality)
222
+ - MIDPOINT solver: 64 effective steps (slower, potentially higher quality)
223
  """)
224
 
225
  # ========== STEP 1: GENERATE ==========
 
260
  transform_solver = gr.Dropdown(
261
  label="Solver",
262
  choices=["euler", "midpoint"],
263
+ value="euler",
264
+ info="EULER: faster (25 steps), MIDPOINT: slower but potentially higher quality (64 steps)"
265
  )
266
  transform_flowstep = gr.Slider(
267
  label="Transform Intensity (Flowstep)",