final model
Browse files
app.py
CHANGED
@@ -243,258 +243,6 @@ gr_interface = gr.Interface(
|
|
243 |
|
244 |
|
245 |
if __name__ == "__main__":
|
246 |
-
|
247 |
-
|
248 |
-
gr_interface.queue(15).launch()
|
249 |
-
|
250 |
-
# theme = gr.themes.Soft(
|
251 |
-
# primary_hue="blue",
|
252 |
-
# secondary_hue="slate",
|
253 |
-
# neutral_hue="slate",
|
254 |
-
# text_size="sm",
|
255 |
-
# spacing_size="sm",
|
256 |
-
# ).set(
|
257 |
-
# background_fill_primary="*neutral_50",
|
258 |
-
# background_fill_secondary="*background_fill_primary",
|
259 |
-
# block_background_fill="*background_fill_primary",
|
260 |
-
# block_border_width="0px",
|
261 |
-
# panel_background_fill="*neutral_50",
|
262 |
-
# panel_border_width="0px",
|
263 |
-
# input_background_fill="*neutral_100",
|
264 |
-
# input_border_color="*neutral_200",
|
265 |
-
# button_primary_background_fill="*primary_300",
|
266 |
-
# button_primary_background_fill_hover="*primary_400",
|
267 |
-
# button_secondary_background_fill="*neutral_200",
|
268 |
-
# button_secondary_background_fill_hover="*neutral_300",
|
269 |
-
# )
|
270 |
-
# custom_css = """
|
271 |
-
# #main-headertitle {
|
272 |
-
# text-align: center;
|
273 |
-
# margin-top: 15px;
|
274 |
-
# margin-bottom: 10px;
|
275 |
-
# color: var(--neutral-600);
|
276 |
-
# font-weight: 600;
|
277 |
-
# }
|
278 |
-
# #main-header {
|
279 |
-
# text-align: center;
|
280 |
-
# margin-top: 5px;
|
281 |
-
# margin-bottom: 10px;
|
282 |
-
# color: var(--neutral-600);
|
283 |
-
# font-weight: 600;
|
284 |
-
# }
|
285 |
-
# #model-settings-header, #generation-settings-header {
|
286 |
-
# color: var(--neutral-600);
|
287 |
-
# margin-top: 8px;
|
288 |
-
# margin-bottom: 8px;
|
289 |
-
# font-weight: 500;
|
290 |
-
# font-size: 1.1em;
|
291 |
-
# }
|
292 |
-
# .setting-section {
|
293 |
-
# padding: 10px 12px;
|
294 |
-
# border-radius: 6px;
|
295 |
-
# background-color: var(--neutral-50);
|
296 |
-
# margin-bottom: 10px;
|
297 |
-
# border: 1px solid var(--neutral-100);
|
298 |
-
# }
|
299 |
-
# hr {
|
300 |
-
# border: none;
|
301 |
-
# height: 1px;
|
302 |
-
# background-color: var(--neutral-200);
|
303 |
-
# margin: 8px 0;
|
304 |
-
# }
|
305 |
-
# #generate-btn {
|
306 |
-
# width: 100%;
|
307 |
-
# max-width: 250px;
|
308 |
-
# margin: 10px auto;
|
309 |
-
# display: block;
|
310 |
-
# padding: 10px 15px;
|
311 |
-
# font-size: 16px;
|
312 |
-
# border-radius: 5px;
|
313 |
-
# }
|
314 |
-
# #status-box {
|
315 |
-
# min-height: 50px;
|
316 |
-
# display: flex;
|
317 |
-
# align-items: center;
|
318 |
-
# justify-content: center;
|
319 |
-
# padding: 8px;
|
320 |
-
# border-radius: 5px;
|
321 |
-
# border: 1px solid var(--neutral-200);
|
322 |
-
# color: var(--neutral-700);
|
323 |
-
# }
|
324 |
-
# #project-badges {
|
325 |
-
# text-align: center;
|
326 |
-
# margin-top: 30px;
|
327 |
-
# margin-bottom: 20px;
|
328 |
-
# }
|
329 |
-
# #project-badges #badge-container {
|
330 |
-
# display: flex;
|
331 |
-
# gap: 10px;
|
332 |
-
# align-items: center;
|
333 |
-
# justify-content: center;
|
334 |
-
# flex-wrap: wrap;
|
335 |
-
# }
|
336 |
-
# #project-badges img {
|
337 |
-
# border-radius: 5px;
|
338 |
-
# box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
339 |
-
# height: 20px;
|
340 |
-
# transition: transform 0.1s ease, box-shadow 0.1s ease;
|
341 |
-
# }
|
342 |
-
# #project-badges a:hover img {
|
343 |
-
# transform: translateY(-2px);
|
344 |
-
# box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
|
345 |
-
# }
|
346 |
-
# #audio-output {
|
347 |
-
# height: 200px;
|
348 |
-
# border-radius: 5px;
|
349 |
-
# border: 1px solid var(--neutral-200);
|
350 |
-
# }
|
351 |
-
# .gradio-dropdown label, .gradio-checkbox label, .gradio-number label, .gradio-textbox label {
|
352 |
-
# font-weight: 500;
|
353 |
-
# color: var(--neutral-700);
|
354 |
-
# font-size: 0.9em;
|
355 |
-
# }
|
356 |
-
# .gradio-row {
|
357 |
-
# gap: 8px;
|
358 |
-
# }
|
359 |
-
# .gradio-block {
|
360 |
-
# margin-bottom: 8px;
|
361 |
-
# }
|
362 |
-
# .setting-section .gradio-block {
|
363 |
-
# margin-bottom: 6px;
|
364 |
-
# }
|
365 |
-
# ::-webkit-scrollbar {
|
366 |
-
# width: 8px;
|
367 |
-
# height: 8px;
|
368 |
-
# }
|
369 |
-
# ::-webkit-scrollbar-track {
|
370 |
-
# background: var(--neutral-100);
|
371 |
-
# border-radius: 4px;
|
372 |
-
# }
|
373 |
-
# ::-webkit-scrollbar-thumb {
|
374 |
-
# background: var(--neutral-300);
|
375 |
-
# border-radius: 4px;
|
376 |
-
# }
|
377 |
-
# ::-webkit-scrollbar-thumb:hover {
|
378 |
-
# background: var(--neutral-400);
|
379 |
-
# }
|
380 |
-
# * {
|
381 |
-
# scrollbar-width: thin;
|
382 |
-
# scrollbar-color: var(--neutral-300) var(--neutral-100);
|
383 |
-
# }
|
384 |
-
# """
|
385 |
-
# with gr.Blocks(title="MeanAudio Generator", theme=theme, css=custom_css) as demo:
|
386 |
-
# gr.Markdown("# MeanAudio: Fast and Faithful Text-to-Audio Generation with Mean Flows", elem_id="main-header")
|
387 |
-
# badge_html = '''
|
388 |
-
# <div id="project-badges"> <!-- 使用 ID
|
389 |
-
# 以便应用 CSS -->
|
390 |
-
# <div id="badge-container"> <!-- 添加这个容器 div 并使用 ID -->
|
391 |
-
# <a href="https://huggingface.co/junxiliu/MeanAudio">
|
392 |
-
# <img src="https://img.shields.io/badge/Model-HuggingFace-violet?logo=huggingface" alt="Hugging Face Model">
|
393 |
-
# </a>
|
394 |
-
# <a href="https://huggingface.co/spaces/chenxie95/MeanAudio">
|
395 |
-
# <img src="https://img.shields.io/badge/Space-HuggingFace-8A2BE2?logo=huggingface" alt="Hugging Face Space">
|
396 |
-
# </a>
|
397 |
-
# <a href="https://meanaudio.github.io/">
|
398 |
-
# <img src="https://img.shields.io/badge/Project-Page-brightred?style=flat" alt="Project Page">
|
399 |
-
# </a>
|
400 |
-
# <a href="https://github.com/xiquan-li/MeanAudio">
|
401 |
-
# <img src="https://img.shields.io/badge/Code-GitHub-black?logo=github" alt="GitHub">
|
402 |
-
# </a>
|
403 |
-
# </div>
|
404 |
-
# </div>
|
405 |
-
# '''
|
406 |
-
# gr.HTML(badge_html)
|
407 |
-
# with gr.Column(elem_classes="setting-section"):
|
408 |
-
# with gr.Row():
|
409 |
-
# available_variants = (
|
410 |
-
# list(all_model_cfg.keys()) if all_model_cfg else []
|
411 |
-
# )
|
412 |
-
# default_variant = (
|
413 |
-
# 'meanaudio_mf'
|
414 |
-
# )
|
415 |
-
# variant = gr.Dropdown(
|
416 |
-
# label="Model Variant",
|
417 |
-
# choices=available_variants,
|
418 |
-
# value=default_variant,
|
419 |
-
# interactive=True,
|
420 |
-
# scale=3,
|
421 |
-
# )
|
422 |
-
# with gr.Column(elem_classes="setting-section"):
|
423 |
-
# with gr.Row():
|
424 |
-
# prompt = gr.Textbox(
|
425 |
-
# label="Prompt",
|
426 |
-
# placeholder="Describe the sound you want to generate...",
|
427 |
-
# scale=1,
|
428 |
-
# )
|
429 |
-
# negative_prompt = gr.Textbox(
|
430 |
-
# label="Negative Prompt",
|
431 |
-
# placeholder="Describe sounds you want to avoid...",
|
432 |
-
# value="",
|
433 |
-
# scale=1,
|
434 |
-
# )
|
435 |
-
# with gr.Row():
|
436 |
-
# duration = gr.Number(
|
437 |
-
# label="Duration (sec)", value=10.0, minimum=0.1, scale=1
|
438 |
-
# )
|
439 |
-
# cfg_strength = gr.Number(
|
440 |
-
# label="CFG (Meanflow forced to 3)", value=3, minimum=0.0, scale=1
|
441 |
-
# )
|
442 |
-
# with gr.Row():
|
443 |
-
# seed = gr.Number(
|
444 |
-
# label="Seed (-1 for random)", value=42, precision=0, scale=1
|
445 |
-
# )
|
446 |
-
# num_steps = gr.Number(
|
447 |
-
# label="Number of Steps",
|
448 |
-
# value=1,
|
449 |
-
# precision=0,
|
450 |
-
# minimum=1,
|
451 |
-
# scale=1,
|
452 |
-
# )
|
453 |
-
# generate_button = gr.Button("Generate", variant="primary", elem_id="generate-btn")
|
454 |
-
# generate_output_text = gr.Textbox(
|
455 |
-
# label="Result Status", interactive=False, elem_id="status-box"
|
456 |
-
# )
|
457 |
-
# audio_output = gr.Audio(
|
458 |
-
# label="Generated Audio", type="filepath", elem_id="audio-output"
|
459 |
-
# )
|
460 |
-
# generate_button.click(
|
461 |
-
# fn=generate_audio_gradio,
|
462 |
-
# inputs=[
|
463 |
-
# prompt,
|
464 |
-
# negative_prompt,
|
465 |
-
# duration,
|
466 |
-
# cfg_strength,
|
467 |
-
# num_steps,
|
468 |
-
# seed,
|
469 |
-
# variant,
|
470 |
-
# ],
|
471 |
-
# outputs=[generate_output_text, audio_output],
|
472 |
-
# )
|
473 |
-
# audio_examples = [
|
474 |
-
# ["Typing on a keyboard", "", 10.0, 3, 1, 42, "meanaudio_mf"],
|
475 |
-
# ["A man speaks followed by a popping noise and laughter", "", 10.0, 3, 1, 42, "meanaudio_mf"],
|
476 |
-
# ["Some humming followed by a toilet flushing", "", 10.0, 3, 2, 42, "meanaudio_mf"],
|
477 |
-
# ["Rain falling on a hard surface as thunder roars in the distance", "", 10.0, 3, 5, 42, "meanaudio_mf"],
|
478 |
-
# ["Food sizzling and oil popping", "", 10.0, 3, 25, 42, "meanaudio_mf"],
|
479 |
-
# ["Pots and dishes clanking as a man talks followed by liquid pouring into a container", "", 8.0, 3, 2, 42, "meanaudio_mf"],
|
480 |
-
# ["A few seconds of silence then a rasping sound against wood", "", 12.0, 3, 2, 42, "meanaudio_mf"],
|
481 |
-
# ["A man speaks as he gives a speech and then the crowd cheers", "", 10.0, 3, 25, 42, "fluxaudio_fm"],
|
482 |
-
# ["A goat bleating repeatedly", "", 10.0, 3, 50, 123, "fluxaudio_fm"],
|
483 |
-
# ["A speech and gunfire followed by a gun being loaded", "", 10.0, 3, 1, 42, "meanaudio_mf"],
|
484 |
-
# ["Tires squealing followed by an engine revving", "", 12.0, 4, 25, 456, "fluxaudio_fm"],
|
485 |
-
# ["Hammer slowly hitting the wooden table", "", 10.0, 3.5, 25, 42, "fluxaudio_fm"],
|
486 |
-
# ["Dog barking excitedly and man shouting as race car engine roars past", "", 10.0, 3, 1, 42, "meanaudio_mf"],
|
487 |
-
# ["A dog barking and a cat mewing and a racing car passes by", "", 12.0, 3, 5, -1, "meanaudio_mf"],
|
488 |
-
# ["Whistling with birds chirping", "", 10.0, 4, 50, 42, "fluxaudio_fm"],
|
489 |
-
# ]
|
490 |
-
# gr.Examples(
|
491 |
-
# examples=audio_examples,
|
492 |
-
# inputs=[prompt, negative_prompt, duration, cfg_strength, num_steps, seed, variant],
|
493 |
-
# #outputs=[generate_output_text, audio_output],
|
494 |
-
# #fn=generate_audio_gradio,
|
495 |
-
# examples_per_page=5,
|
496 |
-
# label="Example Prompts",
|
497 |
-
# )
|
498 |
-
|
499 |
-
# if __name__ == "__main__":
|
500 |
-
# demo.launch()
|
|
|
243 |
|
244 |
|
245 |
if __name__ == "__main__":
|
246 |
+
ensure_models_downloaded()
|
247 |
+
load_model_cache()
|
248 |
+
gr_interface.queue(15).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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