tianfengping.tfp commited on
Commit
758e8f9
·
1 Parent(s): 9dfd458

waiting for logo

Browse files
Files changed (1) hide show
  1. app.py +25 -8
app.py CHANGED
@@ -70,7 +70,20 @@ def load_assets():
70
 
71
  # Start downloading assets in background (non-blocking)
72
  import threading
73
- threading.Thread(target=load_assets, daemon=True).start()
 
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
  # Delay model download to avoid blocking startup
76
  model_repo_id = "AIDC-AI/Marco-Voice"
@@ -661,13 +674,17 @@ input[type="text"]:focus, textarea:focus {
661
  with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
662
  with gr.Column(elem_classes="header"):
663
  with gr.Row(elem_id="header-row", variant="compact"):
664
- # Load logo if available, otherwise use placeholder
665
- logo_value = logo_path if logo_path is not None else None
666
- gr.Image(value=logo_value,
667
- elem_id="logo-container",
668
- show_label=False,
669
- show_download_button=False,
670
- show_share_button=False)
 
 
 
 
671
 
672
  with gr.Column(elem_id="title-area"):
673
  gr.Markdown("# 🎤 Marco-Voice ", elem_id="header-title")
 
70
 
71
  # Start downloading assets in background (non-blocking)
72
  import threading
73
+ import time
74
+ assets_download_thread = threading.Thread(target=load_assets, daemon=True)
75
+ assets_download_thread.start()
76
+
77
+ # Wait for assets to download (with timeout) before creating UI
78
+ # This ensures logo is available when UI is created
79
+ max_wait_time = 30 # Maximum wait time in seconds
80
+ wait_interval = 0.5 # Check every 0.5 seconds
81
+ elapsed = 0
82
+ while logo_path is None and elapsed < max_wait_time:
83
+ time.sleep(wait_interval)
84
+ elapsed += wait_interval
85
+ if logo_path is None:
86
+ print("Warning: Logo download timed out, UI will be created without logo")
87
 
88
  # Delay model download to avoid blocking startup
89
  model_repo_id = "AIDC-AI/Marco-Voice"
 
674
  with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
675
  with gr.Column(elem_classes="header"):
676
  with gr.Row(elem_id="header-row", variant="compact"):
677
+ # Load logo if available, otherwise hide the component to avoid showing upload interface
678
+ # Note: gr.Image with value=None shows upload interface, so we use visible=False if no logo
679
+ logo_exists = logo_path is not None and os.path.exists(logo_path) if logo_path else False
680
+ logo_image = gr.Image(
681
+ value=logo_path if logo_exists else None,
682
+ elem_id="logo-container",
683
+ show_label=False,
684
+ show_download_button=False,
685
+ show_share_button=False,
686
+ visible=logo_exists
687
+ )
688
 
689
  with gr.Column(elem_id="title-area"):
690
  gr.Markdown("# 🎤 Marco-Voice ", elem_id="header-title")