Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -209,17 +209,12 @@ load_resources()
|
|
| 209 |
model_files = glob.glob(os.path.join(MODELS_DIR, "*.pt"))
|
| 210 |
model_choices = [os.path.basename(f) for f in model_files]
|
| 211 |
|
| 212 |
-
|
| 213 |
-
default_model = 'musicflow_b.pt'
|
| 214 |
-
if default_model in model_choices:
|
| 215 |
-
model_choices.remove(default_model)
|
| 216 |
-
model_choices.insert(0, default_model)
|
| 217 |
|
| 218 |
# Handle the case where no models are found
|
| 219 |
if not model_choices:
|
| 220 |
print("No model files found in the specified directory.")
|
| 221 |
model_choices = ["No models available"]
|
| 222 |
-
default_model = "No models available"
|
| 223 |
|
| 224 |
# Set up dark grey theme
|
| 225 |
theme = gr.themes.Monochrome(
|
|
@@ -240,7 +235,7 @@ with gr.Blocks(theme=theme) as iface:
|
|
| 240 |
""")
|
| 241 |
|
| 242 |
with gr.Row():
|
| 243 |
-
model_dropdown = gr.Dropdown(choices=model_choices, label="Select Model", value=
|
| 244 |
|
| 245 |
with gr.Row():
|
| 246 |
prompt = gr.Textbox(label="Prompt")
|
|
@@ -264,13 +259,11 @@ with gr.Blocks(theme=theme) as iface:
|
|
| 264 |
model_dropdown.change(on_model_change, inputs=[model_dropdown])
|
| 265 |
generate_button.click(generate_music, inputs=[prompt, seed, cfg_scale, steps, duration], outputs=[output_status, output_audio])
|
| 266 |
|
| 267 |
-
# Load
|
| 268 |
-
if
|
| 269 |
-
|
| 270 |
-
if os.path.exists(default_model_path):
|
| 271 |
-
iface.load(lambda: load_model(default_model), inputs=None, outputs=None)
|
| 272 |
else:
|
| 273 |
-
print("No
|
| 274 |
|
| 275 |
# Launch the interface
|
| 276 |
-
iface.launch()
|
|
|
|
| 209 |
model_files = glob.glob(os.path.join(MODELS_DIR, "*.pt"))
|
| 210 |
model_choices = [os.path.basename(f) for f in model_files]
|
| 211 |
|
| 212 |
+
print(f"Found model files: {model_choices}") # Debug print
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
# Handle the case where no models are found
|
| 215 |
if not model_choices:
|
| 216 |
print("No model files found in the specified directory.")
|
| 217 |
model_choices = ["No models available"]
|
|
|
|
| 218 |
|
| 219 |
# Set up dark grey theme
|
| 220 |
theme = gr.themes.Monochrome(
|
|
|
|
| 235 |
""")
|
| 236 |
|
| 237 |
with gr.Row():
|
| 238 |
+
model_dropdown = gr.Dropdown(choices=model_choices, label="Select Model", value=model_choices[0])
|
| 239 |
|
| 240 |
with gr.Row():
|
| 241 |
prompt = gr.Textbox(label="Prompt")
|
|
|
|
| 259 |
model_dropdown.change(on_model_change, inputs=[model_dropdown])
|
| 260 |
generate_button.click(generate_music, inputs=[prompt, seed, cfg_scale, steps, duration], outputs=[output_status, output_audio])
|
| 261 |
|
| 262 |
+
# Load first available model on startup
|
| 263 |
+
if model_choices[0] != "No models available":
|
| 264 |
+
iface.load(lambda: load_model(model_choices[0]), inputs=None, outputs=None)
|
|
|
|
|
|
|
| 265 |
else:
|
| 266 |
+
print("No models available to load.")
|
| 267 |
|
| 268 |
# Launch the interface
|
| 269 |
+
iface.launch()
|