DontPlanToEnd
commited on
Commit
β’
89b4b95
1
Parent(s):
166ac61
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
|
|
2 |
import pandas as pd
|
3 |
import numpy as np
|
4 |
from functools import partial
|
|
|
5 |
|
6 |
custom_css = """
|
7 |
.tab-nav button {
|
@@ -63,7 +64,7 @@ def load_leaderboard_data(csv_file_path):
|
|
63 |
return pd.DataFrame(columns=UGI_COLS + WRITING_STYLE_COLS + ANIME_RATING_COLS)
|
64 |
|
65 |
# Update the leaderboard table based on the search query and parameter range filters
|
66 |
-
def update_table(df: pd.DataFrame, query: str, param_ranges: list, columns: list,
|
67 |
filtered_df = df.copy()
|
68 |
if param_ranges:
|
69 |
param_mask = pd.Series(False, index=filtered_df.index)
|
@@ -91,7 +92,7 @@ def update_table(df: pd.DataFrame, query: str, param_ranges: list, columns: list
|
|
91 |
|
92 |
# Apply W/10 filtering
|
93 |
if 'W/10 π' in filtered_df.columns:
|
94 |
-
filtered_df = filtered_df[(filtered_df['W/10 π'] >=
|
95 |
|
96 |
return filtered_df[columns]
|
97 |
|
@@ -126,8 +127,7 @@ with GraInter:
|
|
126 |
elem_id="filter-columns-size",
|
127 |
)
|
128 |
with gr.Row():
|
129 |
-
|
130 |
-
w10_max = gr.Slider(minimum=0, maximum=10, value=10, step=0.1, label="Max W/10")
|
131 |
|
132 |
# Load the initial leaderboard data
|
133 |
leaderboard_df = load_leaderboard_data("ugi-leaderboard-data.csv")
|
@@ -247,42 +247,36 @@ with GraInter:
|
|
247 |
**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.
|
248 |
""")
|
249 |
|
250 |
-
def update_all_tables(query, param_ranges,
|
251 |
-
ugi_table = update_table(leaderboard_df, query, param_ranges, UGI_COLS,
|
252 |
|
253 |
ws_df = leaderboard_df.sort_values(by='Reg+MyScore π', ascending=False)
|
254 |
-
ws_table = update_table(ws_df, query, param_ranges, WRITING_STYLE_COLS,
|
255 |
|
256 |
arp_df = leaderboard_df.sort_values(by='Score π', ascending=False)
|
257 |
arp_df_na = arp_df[arp_df[['Dif', 'Cor']].isna().any(axis=1)]
|
258 |
arp_df = arp_df[~arp_df[['Dif', 'Cor']].isna().any(axis=1)]
|
259 |
|
260 |
-
arp_table = update_table(arp_df, query, param_ranges, ANIME_RATING_COLS,
|
261 |
-
arp_na_table = update_table(arp_df_na, query, param_ranges, ANIME_RATING_COLS,
|
262 |
|
263 |
return ugi_table, ws_table, arp_table, arp_na_table
|
264 |
|
265 |
search_bar.change(
|
266 |
fn=update_all_tables,
|
267 |
-
inputs=[search_bar, filter_columns_size,
|
268 |
outputs=[leaderboard_table_ugi, leaderboard_table_ws, leaderboard_table_arp, leaderboard_table_arp_na]
|
269 |
)
|
270 |
|
271 |
filter_columns_size.change(
|
272 |
fn=update_all_tables,
|
273 |
-
inputs=[search_bar, filter_columns_size,
|
274 |
outputs=[leaderboard_table_ugi, leaderboard_table_ws, leaderboard_table_arp, leaderboard_table_arp_na]
|
275 |
)
|
276 |
|
277 |
-
|
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 |
-
w10_max.change(
|
284 |
-
fn=update_all_tables,
|
285 |
-
inputs=[search_bar, filter_columns_size, w10_min, w10_max],
|
286 |
outputs=[leaderboard_table_ugi, leaderboard_table_ws, leaderboard_table_arp, leaderboard_table_arp_na]
|
287 |
)
|
288 |
|
|
|
2 |
import pandas as pd
|
3 |
import numpy as np
|
4 |
from functools import partial
|
5 |
+
from gradio_rangeslider import RangeSlider
|
6 |
|
7 |
custom_css = """
|
8 |
.tab-nav button {
|
|
|
64 |
return pd.DataFrame(columns=UGI_COLS + WRITING_STYLE_COLS + ANIME_RATING_COLS)
|
65 |
|
66 |
# Update the leaderboard table based on the search query and parameter range filters
|
67 |
+
def update_table(df: pd.DataFrame, query: str, param_ranges: list, columns: list, w10_range: tuple) -> pd.DataFrame:
|
68 |
filtered_df = df.copy()
|
69 |
if param_ranges:
|
70 |
param_mask = pd.Series(False, index=filtered_df.index)
|
|
|
92 |
|
93 |
# Apply W/10 filtering
|
94 |
if 'W/10 π' in filtered_df.columns:
|
95 |
+
filtered_df = filtered_df[(filtered_df['W/10 π'] >= w10_range[0]) & (filtered_df['W/10 π'] <= w10_range[1])]
|
96 |
|
97 |
return filtered_df[columns]
|
98 |
|
|
|
127 |
elem_id="filter-columns-size",
|
128 |
)
|
129 |
with gr.Row():
|
130 |
+
w10_range = RangeSlider(minimum=0, maximum=10, value=(0, 10), step=0.1, label="W/10 Range")
|
|
|
131 |
|
132 |
# Load the initial leaderboard data
|
133 |
leaderboard_df = load_leaderboard_data("ugi-leaderboard-data.csv")
|
|
|
247 |
**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.
|
248 |
""")
|
249 |
|
250 |
+
def update_all_tables(query, param_ranges, w10_range):
|
251 |
+
ugi_table = update_table(leaderboard_df, query, param_ranges, UGI_COLS, w10_range)
|
252 |
|
253 |
ws_df = leaderboard_df.sort_values(by='Reg+MyScore π', ascending=False)
|
254 |
+
ws_table = update_table(ws_df, query, param_ranges, WRITING_STYLE_COLS, w10_range)
|
255 |
|
256 |
arp_df = leaderboard_df.sort_values(by='Score π', ascending=False)
|
257 |
arp_df_na = arp_df[arp_df[['Dif', 'Cor']].isna().any(axis=1)]
|
258 |
arp_df = arp_df[~arp_df[['Dif', 'Cor']].isna().any(axis=1)]
|
259 |
|
260 |
+
arp_table = update_table(arp_df, query, param_ranges, ANIME_RATING_COLS, w10_range)
|
261 |
+
arp_na_table = update_table(arp_df_na, query, param_ranges, ANIME_RATING_COLS, w10_range).fillna('NA')
|
262 |
|
263 |
return ugi_table, ws_table, arp_table, arp_na_table
|
264 |
|
265 |
search_bar.change(
|
266 |
fn=update_all_tables,
|
267 |
+
inputs=[search_bar, filter_columns_size, w10_range],
|
268 |
outputs=[leaderboard_table_ugi, leaderboard_table_ws, leaderboard_table_arp, leaderboard_table_arp_na]
|
269 |
)
|
270 |
|
271 |
filter_columns_size.change(
|
272 |
fn=update_all_tables,
|
273 |
+
inputs=[search_bar, filter_columns_size, w10_range],
|
274 |
outputs=[leaderboard_table_ugi, leaderboard_table_ws, leaderboard_table_arp, leaderboard_table_arp_na]
|
275 |
)
|
276 |
|
277 |
+
w10_range.change(
|
278 |
fn=update_all_tables,
|
279 |
+
inputs=[search_bar, filter_columns_size, w10_range],
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
outputs=[leaderboard_table_ugi, leaderboard_table_ws, leaderboard_table_arp, leaderboard_table_arp_na]
|
281 |
)
|
282 |
|