Update app.py
Browse files
app.py
CHANGED
|
@@ -39,56 +39,137 @@ def get_leaderboard_df(score_path):
|
|
| 39 |
|
| 40 |
leaderboard_df = get_leaderboard_df("score.json")
|
| 41 |
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
#
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
df = df[df["Model"].str.lower().str.contains(pattern, regex=True)]
|
| 53 |
-
# Drop any columns which are all NaN
|
| 54 |
-
df = df.dropna(how="all", axis=1)
|
| 55 |
-
|
| 56 |
-
if len(cols) > 0:
|
| 57 |
-
index_cols = list(leaderboard_df.columns[:1])
|
| 58 |
-
new_cols = index_cols + cols
|
| 59 |
-
df = df.copy()[new_cols]
|
| 60 |
-
df = df.copy().dropna(how="all", axis=0, subset=[c for c in df.columns if c in cols])
|
| 61 |
-
|
| 62 |
-
df[cols] = df[cols].apply(pd.to_numeric, errors='coerce')
|
| 63 |
-
df = df.sort_values(by=cols, ascending=False, na_position='last')
|
| 64 |
-
df[cols] = df[cols].astype(str)
|
| 65 |
-
return df
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
-
|
|
|
|
|
|
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
|
|
|
| 72 |
with gr.Column():
|
| 73 |
-
gr.Markdown(
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
demo.launch()
|
|
|
|
| 39 |
|
| 40 |
leaderboard_df = get_leaderboard_df("score.json")
|
| 41 |
|
| 42 |
+
import gradio as gr
|
| 43 |
+
import pandas as pd
|
| 44 |
|
| 45 |
+
# 示例:你已有的 dataframe
|
| 46 |
+
# leaderboard_df = pd.read_csv("your_data.csv")
|
| 47 |
+
|
| 48 |
+
# 示例任务列字典
|
| 49 |
+
TASKS = {
|
| 50 |
+
"VQA": ["VQA"],
|
| 51 |
+
"QA": ["QA"],
|
| 52 |
+
"VQA Reasoning": ["VQA_Reasoning"],
|
| 53 |
+
"Reason": ["Reason"], # 请确保这个列名正确
|
| 54 |
+
"Embodied Grounding": ["Embodied Grounding"],
|
| 55 |
+
"GUI Grounding": ["Gui Grounding"],
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
# 筛选函数:只根据模型名称关键词搜索
|
| 59 |
+
def filter_and_search(search_query: str, task_name: str):
|
| 60 |
+
df = leaderboard_df.copy()
|
| 61 |
+
task_cols = TASKS[task_name]
|
| 62 |
+
score_col = task_cols[0]
|
| 63 |
+
|
| 64 |
+
df[score_col] = pd.to_numeric(df[score_col], errors='coerce')
|
| 65 |
+
df = df.sort_values(by=score_col, ascending=False, na_position='last')
|
| 66 |
+
|
| 67 |
+
if search_query.strip():
|
| 68 |
+
terms = [term.strip().lower() for term in search_query.split(";")]
|
| 69 |
+
pattern = "|".join(terms)
|
| 70 |
df = df[df["Model"].str.lower().str.contains(pattern, regex=True)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
+
return df[["Model"] + task_cols]
|
| 73 |
+
|
| 74 |
+
# Gradio UI 构建
|
| 75 |
+
with gr.Blocks() as demo:
|
| 76 |
+
gr.HTML("<h2>Leaderboard</h2>")
|
| 77 |
+
with gr.Column():
|
| 78 |
+
gr.Markdown("Search and view results for each task.", elem_classes="markdown-text")
|
| 79 |
+
|
| 80 |
+
with gr.Tabs(elem_classes="tabs-buttons") as tabs:
|
| 81 |
+
for task_name, task_cols in TASKS.items():
|
| 82 |
+
with gr.TabItem(task_name):
|
| 83 |
+
# 初始数据:按得分降序
|
| 84 |
+
sub_df = leaderboard_df[["Model"] + task_cols].copy()
|
| 85 |
+
sub_df[task_cols[0]] = pd.to_numeric(sub_df[task_cols[0]], errors="coerce")
|
| 86 |
+
sub_df = sub_df.sort_values(by=task_cols[0], ascending=False, na_position="last")
|
| 87 |
+
|
| 88 |
+
with gr.Row():
|
| 89 |
+
search_bar = gr.Textbox(placeholder="Search model name...", show_label=False)
|
| 90 |
+
|
| 91 |
+
with gr.Group():
|
| 92 |
+
table = gr.Dataframe(
|
| 93 |
+
value=sub_df,
|
| 94 |
+
wrap=True,
|
| 95 |
+
column_widths=[400] + [110 for _ in task_cols],
|
| 96 |
+
)
|
| 97 |
+
|
| 98 |
+
# 绑定搜索逻辑
|
| 99 |
+
search_bar.submit(
|
| 100 |
+
fn=lambda query, t=task_name: filter_and_search(query, t),
|
| 101 |
+
inputs=search_bar,
|
| 102 |
+
outputs=table,
|
| 103 |
+
)
|
| 104 |
+
|
| 105 |
+
gr.HTML("Threshold corresponding to the values of GUI and Embodied Grounding: <b>20</b>")
|
| 106 |
+
|
| 107 |
+
demo.launch()
|
| 108 |
+
|
| 109 |
+
# 筛选函数:只根据模型名称关键词搜索
|
| 110 |
+
def filter_and_search(search_query: str, task_name: str):
|
| 111 |
+
df = leaderboard_df.copy()
|
| 112 |
+
task_cols = TASKS[task_name]
|
| 113 |
+
score_col = task_cols[0]
|
| 114 |
+
|
| 115 |
+
df[score_col] = pd.to_numeric(df[score_col], errors='coerce')
|
| 116 |
+
df = df.sort_values(by=score_col, ascending=False, na_position='last')
|
| 117 |
+
|
| 118 |
+
if search_query.strip():
|
| 119 |
+
terms = [term.strip().lower() for term in search_query.split(";")]
|
| 120 |
+
pattern = "|".join(terms)
|
| 121 |
+
df = df[df["Model"].str.lower().str.contains(pattern, regex=True)]
|
| 122 |
+
|
| 123 |
+
return df[["Model"] + task_cols]
|
| 124 |
+
|
| 125 |
+
def get_initial_table(task_name: str):
|
| 126 |
+
df = leaderboard_df.copy()
|
| 127 |
+
task_cols = TASKS[task_name]
|
| 128 |
+
score_col = task_cols[0]
|
| 129 |
|
| 130 |
+
df[score_col] = pd.to_numeric(df[score_col], errors='coerce')
|
| 131 |
+
df = df.sort_values(by=score_col, ascending=False, na_position='last')
|
| 132 |
+
return df[["Model"] + task_cols]
|
| 133 |
|
| 134 |
+
# Gradio UI 构建
|
| 135 |
+
with gr.Blocks() as demo:
|
| 136 |
+
gr.HTML("<h2>Leaderboard</h2>")
|
| 137 |
with gr.Column():
|
| 138 |
+
gr.Markdown("Search and view results for each task.", elem_classes="markdown-text")
|
| 139 |
+
|
| 140 |
+
with gr.Tabs(elem_classes="tabs-buttons") as tabs:
|
| 141 |
+
for task_name, task_cols in TASKS.items():
|
| 142 |
+
with gr.TabItem(task_name):
|
| 143 |
+
# 初始数据:按得分降序
|
| 144 |
+
sub_df = leaderboard_df[["Model"] + task_cols].copy()
|
| 145 |
+
sub_df[task_cols[0]] = pd.to_numeric(sub_df[task_cols[0]], errors="coerce")
|
| 146 |
+
sub_df = sub_df.sort_values(by=task_cols[0], ascending=False, na_position="last")
|
| 147 |
+
|
| 148 |
+
with gr.Row():
|
| 149 |
+
search_bar = gr.Textbox(placeholder="Search model name...", show_label=False)
|
| 150 |
+
|
| 151 |
+
refresh_btn = gr.Button("Refresh")
|
| 152 |
+
with gr.Group():
|
| 153 |
+
table = gr.Dataframe(
|
| 154 |
+
value=sub_df,
|
| 155 |
+
wrap=True,
|
| 156 |
+
column_widths=[400] + [110 for _ in task_cols],
|
| 157 |
+
)
|
| 158 |
+
|
| 159 |
+
# 绑定搜索逻辑
|
| 160 |
+
search_bar.submit(
|
| 161 |
+
fn=lambda query, t=task_name: filter_and_search(query, t),
|
| 162 |
+
inputs=search_bar,
|
| 163 |
+
outputs=table,
|
| 164 |
+
)
|
| 165 |
+
def refresh(task=task_name):
|
| 166 |
+
return "", get_initial_table(task)
|
| 167 |
+
|
| 168 |
+
refresh_btn.click(
|
| 169 |
+
fn=refresh,
|
| 170 |
+
outputs=[search_bar, table]
|
| 171 |
+
)
|
| 172 |
+
|
| 173 |
+
gr.HTML("Threshold corresponding to the values of GUI and Embodied Grounding: <b>20</b>")
|
| 174 |
|
| 175 |
demo.launch()
|