Update app.py
Browse files
app.py
CHANGED
|
@@ -62,7 +62,7 @@ def load_leaderboard_data(csv_file_path):
|
|
| 62 |
return pd.DataFrame(columns=UGI_COLS + WRITING_STYLE_COLS + ANIME_RATING_COLS)
|
| 63 |
|
| 64 |
# Update the leaderboard table based on the search query and parameter range filters
|
| 65 |
-
def update_table(df: pd.DataFrame, query: str, param_ranges: list,
|
| 66 |
filtered_df = df.copy()
|
| 67 |
if param_ranges:
|
| 68 |
param_mask = pd.Series(False, index=filtered_df.index)
|
|
@@ -86,7 +86,7 @@ def update_table(df: pd.DataFrame, query: str, param_ranges: list, w10_min: floa
|
|
| 86 |
filtered_df = filtered_df[param_mask]
|
| 87 |
|
| 88 |
# Apply W/10 filter
|
| 89 |
-
filtered_df = filtered_df[(filtered_df['W/10 π'] >=
|
| 90 |
|
| 91 |
if query:
|
| 92 |
filtered_df = filtered_df[filtered_df['Model'].str.contains(query, case=False, na=False)]
|
|
@@ -124,21 +124,13 @@ with GraInter:
|
|
| 124 |
elem_id="filter-columns-size",
|
| 125 |
)
|
| 126 |
with gr.Row():
|
| 127 |
-
|
| 128 |
minimum=0,
|
| 129 |
maximum=10,
|
| 130 |
-
value=0,
|
| 131 |
step=0.1,
|
| 132 |
-
label="W/10
|
| 133 |
-
elem_id="w10-
|
| 134 |
-
)
|
| 135 |
-
w10_max = gr.Slider(
|
| 136 |
-
minimum=0,
|
| 137 |
-
maximum=10,
|
| 138 |
-
value=10,
|
| 139 |
-
step=0.1,
|
| 140 |
-
label="W/10 Maximum",
|
| 141 |
-
elem_id="w10-max-slider"
|
| 142 |
)
|
| 143 |
|
| 144 |
# Load the initial leaderboard data
|
|
@@ -259,42 +251,36 @@ with GraInter:
|
|
| 259 |
**NA:** When models either reply with one number for every anime, give ratings not between 1 and 10, or don't give every anime in the list a rating.
|
| 260 |
""")
|
| 261 |
|
| 262 |
-
def update_all_tables(query, param_ranges,
|
| 263 |
-
ugi_table = update_table(leaderboard_df, query, param_ranges,
|
| 264 |
|
| 265 |
ws_df = leaderboard_df.sort_values(by='Reg+MyScore π', ascending=False)
|
| 266 |
-
ws_table = update_table(ws_df, query, param_ranges,
|
| 267 |
|
| 268 |
arp_df = leaderboard_df.sort_values(by='Score π', ascending=False)
|
| 269 |
arp_df_na = arp_df[arp_df[['Dif', 'Cor']].isna().any(axis=1)]
|
| 270 |
arp_df = arp_df[~arp_df[['Dif', 'Cor']].isna().any(axis=1)]
|
| 271 |
|
| 272 |
-
arp_table = update_table(arp_df, query, param_ranges,
|
| 273 |
-
arp_na_table = update_table(arp_df_na, query, param_ranges,
|
| 274 |
|
| 275 |
return ugi_table, ws_table, arp_table, arp_na_table
|
| 276 |
|
| 277 |
search_bar.change(
|
| 278 |
fn=update_all_tables,
|
| 279 |
-
inputs=[search_bar, filter_columns_size,
|
| 280 |
outputs=[leaderboard_table_ugi, leaderboard_table_ws, leaderboard_table_arp, leaderboard_table_arp_na]
|
| 281 |
)
|
| 282 |
|
| 283 |
filter_columns_size.change(
|
| 284 |
fn=update_all_tables,
|
| 285 |
-
inputs=[search_bar, filter_columns_size,
|
| 286 |
outputs=[leaderboard_table_ugi, leaderboard_table_ws, leaderboard_table_arp, leaderboard_table_arp_na]
|
| 287 |
)
|
| 288 |
|
| 289 |
-
|
| 290 |
-
fn=update_all_tables,
|
| 291 |
-
inputs=[search_bar, filter_columns_size, w10_min, w10_max],
|
| 292 |
-
outputs=[leaderboard_table_ugi, leaderboard_table_ws, leaderboard_table_arp, leaderboard_table_arp_na]
|
| 293 |
-
)
|
| 294 |
-
|
| 295 |
-
w10_max.change(
|
| 296 |
fn=update_all_tables,
|
| 297 |
-
inputs=[search_bar, filter_columns_size,
|
| 298 |
outputs=[leaderboard_table_ugi, leaderboard_table_ws, leaderboard_table_arp, leaderboard_table_arp_na]
|
| 299 |
)
|
| 300 |
|
|
|
|
| 62 |
return pd.DataFrame(columns=UGI_COLS + WRITING_STYLE_COLS + ANIME_RATING_COLS)
|
| 63 |
|
| 64 |
# Update the leaderboard table based on the search query and parameter range filters
|
| 65 |
+
def update_table(df: pd.DataFrame, query: str, param_ranges: list, w10_range: list, columns: list) -> pd.DataFrame:
|
| 66 |
filtered_df = df.copy()
|
| 67 |
if param_ranges:
|
| 68 |
param_mask = pd.Series(False, index=filtered_df.index)
|
|
|
|
| 86 |
filtered_df = filtered_df[param_mask]
|
| 87 |
|
| 88 |
# Apply W/10 filter
|
| 89 |
+
filtered_df = filtered_df[(filtered_df['W/10 π'] >= w10_range[0]) & (filtered_df['W/10 π'] <= w10_range[1])]
|
| 90 |
|
| 91 |
if query:
|
| 92 |
filtered_df = filtered_df[filtered_df['Model'].str.contains(query, case=False, na=False)]
|
|
|
|
| 124 |
elem_id="filter-columns-size",
|
| 125 |
)
|
| 126 |
with gr.Row():
|
| 127 |
+
w10_slider = gr.Slider(
|
| 128 |
minimum=0,
|
| 129 |
maximum=10,
|
| 130 |
+
value=[0, 10],
|
| 131 |
step=0.1,
|
| 132 |
+
label="W/10 Range",
|
| 133 |
+
elem_id="w10-slider"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
)
|
| 135 |
|
| 136 |
# Load the initial leaderboard data
|
|
|
|
| 251 |
**NA:** When models either reply with one number for every anime, give ratings not between 1 and 10, or don't give every anime in the list a rating.
|
| 252 |
""")
|
| 253 |
|
| 254 |
+
def update_all_tables(query, param_ranges, w10_range):
|
| 255 |
+
ugi_table = update_table(leaderboard_df, query, param_ranges, w10_range, UGI_COLS)
|
| 256 |
|
| 257 |
ws_df = leaderboard_df.sort_values(by='Reg+MyScore π', ascending=False)
|
| 258 |
+
ws_table = update_table(ws_df, query, param_ranges, w10_range, WRITING_STYLE_COLS)
|
| 259 |
|
| 260 |
arp_df = leaderboard_df.sort_values(by='Score π', ascending=False)
|
| 261 |
arp_df_na = arp_df[arp_df[['Dif', 'Cor']].isna().any(axis=1)]
|
| 262 |
arp_df = arp_df[~arp_df[['Dif', 'Cor']].isna().any(axis=1)]
|
| 263 |
|
| 264 |
+
arp_table = update_table(arp_df, query, param_ranges, w10_range, ANIME_RATING_COLS)
|
| 265 |
+
arp_na_table = update_table(arp_df_na, query, param_ranges, w10_range, ANIME_RATING_COLS).fillna('NA')
|
| 266 |
|
| 267 |
return ugi_table, ws_table, arp_table, arp_na_table
|
| 268 |
|
| 269 |
search_bar.change(
|
| 270 |
fn=update_all_tables,
|
| 271 |
+
inputs=[search_bar, filter_columns_size, w10_slider],
|
| 272 |
outputs=[leaderboard_table_ugi, leaderboard_table_ws, leaderboard_table_arp, leaderboard_table_arp_na]
|
| 273 |
)
|
| 274 |
|
| 275 |
filter_columns_size.change(
|
| 276 |
fn=update_all_tables,
|
| 277 |
+
inputs=[search_bar, filter_columns_size, w10_slider],
|
| 278 |
outputs=[leaderboard_table_ugi, leaderboard_table_ws, leaderboard_table_arp, leaderboard_table_arp_na]
|
| 279 |
)
|
| 280 |
|
| 281 |
+
w10_slider.change(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
fn=update_all_tables,
|
| 283 |
+
inputs=[search_bar, filter_columns_size, w10_slider],
|
| 284 |
outputs=[leaderboard_table_ugi, leaderboard_table_ws, leaderboard_table_arp, leaderboard_table_arp_na]
|
| 285 |
)
|
| 286 |
|