Commit
·
758464e
1
Parent(s):
ff38c5f
Update demos/musicgen_app.py
Browse files- demos/musicgen_app.py +15 -55
demos/musicgen_app.py
CHANGED
@@ -241,7 +241,7 @@ def toggle_diffusion(choice):
|
|
241 |
return [gr.update(visible=False)]
|
242 |
|
243 |
|
244 |
-
def ui_full(
|
245 |
with gr.Blocks() as interface:
|
246 |
gr.Markdown(
|
247 |
"""
|
@@ -289,12 +289,13 @@ def ui_full(launch_kwargs):
|
|
289 |
cfg_coef = gr.Number(label="Classifier Free Guidance", value=3.0, interactive=True)
|
290 |
with gr.Column():
|
291 |
audio_output = gr.Textbox(label="Generated Music (wav)")
|
292 |
-
|
293 |
-
submit.click(
|
294 |
-
|
|
|
295 |
temperature, cfg_coef],
|
296 |
-
|
297 |
-
|
298 |
|
299 |
gr.Markdown(
|
300 |
"""
|
@@ -341,52 +342,11 @@ def ui_full(launch_kwargs):
|
|
341 |
"""
|
342 |
)
|
343 |
|
344 |
-
interface.queue().launch(
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
help='IP to listen on for connections to Gradio',
|
353 |
-
)
|
354 |
-
parser.add_argument(
|
355 |
-
'--username', type=str, default='', help='Username for authentication'
|
356 |
-
)
|
357 |
-
parser.add_argument(
|
358 |
-
'--password', type=str, default='', help='Password for authentication'
|
359 |
-
)
|
360 |
-
parser.add_argument(
|
361 |
-
'--server_port',
|
362 |
-
type=int,
|
363 |
-
default=0,
|
364 |
-
help='Port to run the server listener on',
|
365 |
-
)
|
366 |
-
parser.add_argument(
|
367 |
-
'--inbrowser', action='store_true', help='Open in browser'
|
368 |
-
)
|
369 |
-
parser.add_argument(
|
370 |
-
'--share', action='store_true', help='Share the gradio UI'
|
371 |
-
)
|
372 |
-
|
373 |
-
args = parser.parse_args()
|
374 |
-
|
375 |
-
launch_kwargs = {}
|
376 |
-
launch_kwargs['server_name'] = args.listen
|
377 |
-
|
378 |
-
if args.username and args.password:
|
379 |
-
launch_kwargs['auth'] = (args.username, args.password)
|
380 |
-
if args.server_port:
|
381 |
-
launch_kwargs['server_port'] = args.server_port
|
382 |
-
if args.inbrowser:
|
383 |
-
launch_kwargs['inbrowser'] = args.inbrowser
|
384 |
-
if args.share:
|
385 |
-
launch_kwargs['share'] = args.share
|
386 |
-
|
387 |
-
logging.basicConfig(level=logging.INFO, stream=sys.stderr)
|
388 |
-
|
389 |
-
# Show the interface
|
390 |
-
# we preload the model to avoid a timeout on the first request
|
391 |
-
load_model('facebook/musicgen-stereo-large')
|
392 |
-
ui_full(launch_kwargs)
|
|
|
241 |
return [gr.update(visible=False)]
|
242 |
|
243 |
|
244 |
+
def ui_full():
|
245 |
with gr.Blocks() as interface:
|
246 |
gr.Markdown(
|
247 |
"""
|
|
|
289 |
cfg_coef = gr.Number(label="Classifier Free Guidance", value=3.0, interactive=True)
|
290 |
with gr.Column():
|
291 |
audio_output = gr.Textbox(label="Generated Music (wav)")
|
292 |
+
|
293 |
+
submit.click(
|
294 |
+
fn=predict_full,
|
295 |
+
inputs=[secret_token, model, model_path, decoder, text, melody, duration, topk, topp,
|
296 |
temperature, cfg_coef],
|
297 |
+
outputs=audio_output,
|
298 |
+
api_name="run")
|
299 |
|
300 |
gr.Markdown(
|
301 |
"""
|
|
|
342 |
"""
|
343 |
)
|
344 |
|
345 |
+
interface.queue(max_size=12).launch()
|
346 |
+
|
347 |
+
logging.basicConfig(level=logging.INFO, stream=sys.stderr)
|
348 |
+
|
349 |
+
# Show the interface
|
350 |
+
# we preload the model to avoid a timeout on the first request
|
351 |
+
load_model('facebook/musicgen-stereo-large')
|
352 |
+
ui_full()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|