DontPlanToEnd
commited on
Commit
β’
36beb49
1
Parent(s):
97f31a0
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, columns: list) -> pd.DataFrame:
|
66 |
filtered_df = df.copy()
|
67 |
if param_ranges:
|
68 |
param_mask = pd.Series(False, index=filtered_df.index)
|
@@ -85,6 +85,9 @@ def update_table(df: pd.DataFrame, query: str, param_ranges: list, columns: list
|
|
85 |
param_mask |= (filtered_df['Params'] >= 65)
|
86 |
filtered_df = filtered_df[param_mask]
|
87 |
|
|
|
|
|
|
|
88 |
if query:
|
89 |
filtered_df = filtered_df[filtered_df['Model'].str.contains(query, case=False, na=False)]
|
90 |
|
@@ -120,6 +123,15 @@ with GraInter:
|
|
120 |
interactive=True,
|
121 |
elem_id="filter-columns-size",
|
122 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
# Load the initial leaderboard data
|
125 |
leaderboard_df = load_leaderboard_data("ugi-leaderboard-data.csv")
|
@@ -239,30 +251,36 @@ with GraInter:
|
|
239 |
**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.
|
240 |
""")
|
241 |
|
242 |
-
def update_all_tables(query, param_ranges):
|
243 |
-
ugi_table = update_table(leaderboard_df, query, param_ranges, UGI_COLS)
|
244 |
|
245 |
ws_df = leaderboard_df.sort_values(by='Reg+MyScore π', ascending=False)
|
246 |
-
ws_table = update_table(ws_df, query, param_ranges, WRITING_STYLE_COLS)
|
247 |
|
248 |
arp_df = leaderboard_df.sort_values(by='Score π', ascending=False)
|
249 |
arp_df_na = arp_df[arp_df[['Dif', 'Cor']].isna().any(axis=1)]
|
250 |
arp_df = arp_df[~arp_df[['Dif', 'Cor']].isna().any(axis=1)]
|
251 |
|
252 |
-
arp_table = update_table(arp_df, query, param_ranges, ANIME_RATING_COLS)
|
253 |
-
arp_na_table = update_table(arp_df_na, query, param_ranges, ANIME_RATING_COLS).fillna('NA')
|
254 |
|
255 |
return ugi_table, ws_table, arp_table, arp_na_table
|
256 |
|
257 |
search_bar.change(
|
258 |
fn=update_all_tables,
|
259 |
-
inputs=[search_bar, filter_columns_size],
|
260 |
outputs=[leaderboard_table_ugi, leaderboard_table_ws, leaderboard_table_arp, leaderboard_table_arp_na]
|
261 |
)
|
262 |
|
263 |
filter_columns_size.change(
|
264 |
fn=update_all_tables,
|
265 |
-
inputs=[search_bar, filter_columns_size],
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
outputs=[leaderboard_table_ugi, leaderboard_table_ws, leaderboard_table_arp, leaderboard_table_arp_na]
|
267 |
)
|
268 |
|
|
|
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)
|
|
|
85 |
param_mask |= (filtered_df['Params'] >= 65)
|
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)]
|
93 |
|
|
|
123 |
interactive=True,
|
124 |
elem_id="filter-columns-size",
|
125 |
)
|
126 |
+
with gr.Row():
|
127 |
+
w10_slider = gr.RangeSlider(
|
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
|
137 |
leaderboard_df = load_leaderboard_data("ugi-leaderboard-data.csv")
|
|
|
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 |
|