Spaces:
Running
Running
File size: 2,203 Bytes
0b97f6a e580cf0 0b97f6a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | 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)
demo.queue(default_concurrency_limit=5)
if __name__ == "__main__":
demo.launch()
|