Spaces:
Runtime error
Runtime error
import spaces | |
import gradio as gr | |
from tabs.FACS_analysis import create_facs_analysis_tab | |
from ui_components import CUSTOM_CSS, HEADER_HTML, DISCLAIMER_HTML | |
# Move load_example to a global scope | |
def load_example(): | |
pass # Your logic here | |
# Define the tab structure | |
TAB_STRUCTURE = [ | |
("Visual Analysis", [ | |
("FACS for Stress, Anxiety, Depression", create_facs_analysis_tab), | |
]) | |
] | |
def create_demo(): | |
# Import model-related functions here to ensure spaces is imported first | |
from app.model import load_models | |
# Load models outside of the Gradio blocks | |
pth_model_static, pth_model_dynamic, cam = load_models() | |
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(pth_model_static, pth_model_dynamic, cam) | |
gr.HTML(DISCLAIMER_HTML) | |
return demo | |
# Create the demo instance | |
demo = create_demo() | |
if __name__ == "__main__": | |
demo.launch() | |