import gradio as gr import torch from tabs.FACS_analysis import create_facs_analysis_tab from ui_components import CUSTOM_CSS, HEADER_HTML, DISCLAIMER_HTML import spaces # Importing spaces to utilize Zero GPU # Define the tab structure TAB_STRUCTURE = [ ("Visual Analysis", [ ("FACS for Stress, Anxiety, Depression", create_facs_analysis_tab), ]) ] # Decorate GPU-dependent function with Zero GPU @spaces.GPU(duration=120) # Allocates GPU for 120 seconds when needed def create_demo(): # Gradio blocks to create the interface with gr.Blocks(css=CUSTOM_CSS) as demo: gr.Markdown(HEADER_HTML) with gr.Tabs(elem_classes=["main-tab"]): for main_tab, sub_tabs in TAB_STRUCTURE: with gr.Tab(main_tab): with gr.Tabs(): for sub_tab, create_fn in sub_tabs: with gr.Tab(sub_tab): create_fn() gr.HTML(DISCLAIMER_HTML) return demo # Create the demo instance demo = create_demo() if __name__ == "__main__": demo.launch()