Spaces:
Running
Running
| import os | |
| import sys | |
| # Add project root and src directory to Python path to enable imports from timebench | |
| # Get the directory containing this file (leaderboard_app/) | |
| current_dir = os.path.dirname(os.path.abspath(__file__)) | |
| # Try multiple paths for timebench import: | |
| # 1. Current directory (if timebench was copied to leaderboard_app/) | |
| # 2. Parent directory's src (for local development: TIME/src/) | |
| # 3. Parent's parent's src (if running from leaderboard_app/) | |
| # Add current directory first (for Space deployment) | |
| if current_dir not in sys.path: | |
| sys.path.insert(0, current_dir) | |
| # Add parent directory's src (for local development) | |
| project_root = os.path.dirname(current_dir) | |
| if project_root not in sys.path: | |
| sys.path.insert(0, project_root) | |
| src_dir = os.path.join(project_root, "src") | |
| if src_dir not in sys.path and os.path.exists(src_dir): | |
| sys.path.insert(0, src_dir) | |
| import gradio as gr | |
| from src.display.css_html_js import custom_css | |
| from src.about import TITLE, INTRODUCTION_TEXT | |
| from src.tab import init_overall_tab, init_per_window_tab, init_per_dataset_tab, init_per_pattern_tab | |
| # Custom head content for responsive design | |
| custom_head = """ | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, user-scalable=yes"> | |
| <style> | |
| /* 响应式设计:让页面自动适配不同屏幕尺寸 */ | |
| html { | |
| width: 100%; | |
| max-width: 100%; | |
| } | |
| body { | |
| width: 100%; | |
| max-width: 100%; | |
| } | |
| </style> | |
| """ | |
| with gr.Blocks(css=custom_css, head=custom_head) as demo: | |
| gr.HTML(TITLE) | |
| gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text") | |
| with gr.Tabs(elem_id="custom-tabs") as tabs: | |
| with gr.Tab("🏅 Overall Performance", id=0): | |
| init_overall_tab() | |
| with gr.Tab("🏅 Per Dataset", id=1): | |
| init_per_dataset_tab(demo) | |
| with gr.Tab("🏅 Per Test Window", id=3): | |
| init_per_window_tab(demo) | |
| with gr.Tab("🏅 Per Pattern", id=4): | |
| init_per_pattern_tab(demo) | |
| # with gr.Tab("📂 Archive", id=5): | |
| # init_archive_tab(demo) | |
| if __name__ == "__main__": | |
| demo.launch() | |