Update app.py
Browse files
app.py
CHANGED
|
@@ -26,35 +26,25 @@ def get_leaderboard_df(score_path):
|
|
| 26 |
if sub_key != "20":
|
| 27 |
continue
|
| 28 |
#row[f"{key}_{sub_key}"] = sub_value
|
| 29 |
-
row[f"{key}"] = sub_value
|
| 30 |
else:
|
| 31 |
row[key] = value
|
| 32 |
rows.append(row)
|
| 33 |
|
| 34 |
df = pd.DataFrame(rows)
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
leaderboard_df = get_leaderboard_df("score.json")
|
| 39 |
|
|
|
|
| 40 |
|
| 41 |
-
def agg_df(df, agg: str = "max"):
|
| 42 |
-
df = df.copy()
|
| 43 |
-
# Drop date and aggregate results by model name
|
| 44 |
-
df = df.drop("Date", axis=1).groupby("Model").agg(agg).reset_index()
|
| 45 |
-
|
| 46 |
-
df.insert(loc=1, column="Average", value=df.mean(axis=1, numeric_only=True))
|
| 47 |
|
| 48 |
-
|
| 49 |
-
df[df.select_dtypes(include=["number"]).columns] *= 100.0
|
| 50 |
-
df = df.sort_values(by=["Average"], ascending=False)
|
| 51 |
-
return df
|
| 52 |
|
| 53 |
|
| 54 |
# Function to update the table based on search query
|
| 55 |
def filter_and_search(cols: list[str], search_query: str, agg: str):
|
|
|
|
| 56 |
df = leaderboard_df
|
| 57 |
-
|
| 58 |
if len(search_query) > 0:
|
| 59 |
search_terms = search_query.split(";")
|
| 60 |
search_terms = [term.strip().lower() for term in search_terms]
|
|
@@ -62,12 +52,16 @@ def filter_and_search(cols: list[str], search_query: str, agg: str):
|
|
| 62 |
df = df[df["Model"].str.lower().str.contains(pattern, regex=True)]
|
| 63 |
# Drop any columns which are all NaN
|
| 64 |
df = df.dropna(how="all", axis=1)
|
|
|
|
| 65 |
if len(cols) > 0:
|
| 66 |
index_cols = list(leaderboard_df.columns[:1])
|
| 67 |
new_cols = index_cols + cols
|
| 68 |
df = df.copy()[new_cols]
|
| 69 |
df = df.copy().dropna(how="all", axis=0, subset=[c for c in df.columns if c in cols])
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
| 71 |
return df
|
| 72 |
|
| 73 |
|
|
@@ -79,21 +73,6 @@ with demo:
|
|
| 79 |
gr.Markdown(DESCRIPTION, elem_classes="markdown-text")
|
| 80 |
with gr.Row():
|
| 81 |
search_bar = gr.Textbox(placeholder="Search for your model...", show_label=False)
|
| 82 |
-
agg = gr.Radio(
|
| 83 |
-
["min", "max", "mean"],
|
| 84 |
-
value="max",
|
| 85 |
-
label="Aggregation",
|
| 86 |
-
info="How to aggregate results for each model",
|
| 87 |
-
)
|
| 88 |
-
|
| 89 |
-
# with gr.Row():
|
| 90 |
-
# agg = gr.Radio(
|
| 91 |
-
# ["20", "50", "100", "200"],
|
| 92 |
-
# value="20",
|
| 93 |
-
# label="Threshold",
|
| 94 |
-
# info="The threshold of gui",
|
| 95 |
-
# )
|
| 96 |
-
|
| 97 |
|
| 98 |
with gr.Row():
|
| 99 |
cols_bar = gr.CheckboxGroup(
|
|
@@ -109,7 +88,7 @@ with demo:
|
|
| 109 |
)
|
| 110 |
|
| 111 |
threshold_text = gr.HTML("Threshold corresponding to the values of gui and embodied: 20")
|
| 112 |
-
cols_bar.change(filter_and_search, inputs=[cols_bar, search_bar
|
| 113 |
-
|
| 114 |
-
|
| 115 |
demo.launch()
|
|
|
|
| 26 |
if sub_key != "20":
|
| 27 |
continue
|
| 28 |
#row[f"{key}_{sub_key}"] = sub_value
|
| 29 |
+
row[f"{key.replace('_', ' ')}"] = sub_value
|
| 30 |
else:
|
| 31 |
row[key] = value
|
| 32 |
rows.append(row)
|
| 33 |
|
| 34 |
df = pd.DataFrame(rows)
|
| 35 |
+
df.iloc[:, 1:] = df.iloc[:, 1:].applymap(lambda x: f"{x * 100:.2f}" if isinstance(x, (int, float)) else x)
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
return df
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
leaderboard_df = get_leaderboard_df("output/score.json")
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
# Function to update the table based on search query
|
| 44 |
def filter_and_search(cols: list[str], search_query: str, agg: str):
|
| 45 |
+
print("filter")
|
| 46 |
df = leaderboard_df
|
| 47 |
+
search_terms = "Model"
|
| 48 |
if len(search_query) > 0:
|
| 49 |
search_terms = search_query.split(";")
|
| 50 |
search_terms = [term.strip().lower() for term in search_terms]
|
|
|
|
| 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 |
|
|
|
|
| 73 |
gr.Markdown(DESCRIPTION, elem_classes="markdown-text")
|
| 74 |
with gr.Row():
|
| 75 |
search_bar = gr.Textbox(placeholder="Search for your model...", show_label=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
with gr.Row():
|
| 78 |
cols_bar = gr.CheckboxGroup(
|
|
|
|
| 88 |
)
|
| 89 |
|
| 90 |
threshold_text = gr.HTML("Threshold corresponding to the values of gui and embodied: 20")
|
| 91 |
+
cols_bar.change(filter_and_search, inputs=[cols_bar, search_bar], outputs=[leaderboard_table])
|
| 92 |
+
search_bar.submit(filter_and_search, inputs=[cols_bar, search_bar], outputs=[leaderboard_table])
|
| 93 |
+
|
| 94 |
demo.launch()
|