DontPlanToEnd commited on
Commit
a980fd7
β€’
1 Parent(s): 2c172cf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -8
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  import pandas as pd
3
  import numpy as np
 
4
 
5
  custom_css = """
6
  .tab-nav button {
@@ -62,7 +63,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)
@@ -88,6 +89,10 @@ def update_table(df: pd.DataFrame, query: str, param_ranges: list, columns: list
88
  if query:
89
  filtered_df = filtered_df[filtered_df['Model'].str.contains(query, case=False, na=False)]
90
 
 
 
 
 
91
  return filtered_df[columns]
92
 
93
  # Define the Gradio interface
@@ -120,6 +125,9 @@ 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 +247,42 @@ 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
 
 
1
  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
  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, w10_min: float, w10_max: float) -> pd.DataFrame:
67
  filtered_df = df.copy()
68
  if param_ranges:
69
  param_mask = pd.Series(False, index=filtered_df.index)
 
89
  if query:
90
  filtered_df = filtered_df[filtered_df['Model'].str.contains(query, case=False, na=False)]
91
 
92
+ # Apply W/10 filtering
93
+ if 'W/10 πŸ‘' in filtered_df.columns:
94
+ filtered_df = filtered_df[(filtered_df['W/10 πŸ‘'] >= w10_min) & (filtered_df['W/10 πŸ‘'] <= w10_max)]
95
+
96
  return filtered_df[columns]
97
 
98
  # Define the Gradio interface
 
125
  interactive=True,
126
  elem_id="filter-columns-size",
127
  )
128
+ with gr.Row():
129
+ w10_min = gr.Slider(minimum=0, maximum=10, value=0, step=0.1, label="Min W/10")
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
  **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_min, w10_max):
251
+ ugi_table = update_table(leaderboard_df, query, param_ranges, UGI_COLS, w10_min, w10_max)
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_min, w10_max)
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_min, w10_max)
261
+ arp_na_table = update_table(arp_df_na, query, param_ranges, ANIME_RATING_COLS, w10_min, w10_max).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_min, w10_max],
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_min, w10_max],
274
+ outputs=[leaderboard_table_ugi, leaderboard_table_ws, leaderboard_table_arp, leaderboard_table_arp_na]
275
+ )
276
+
277
+ w10_min.change(
278
+ fn=update_all_tables,
279
+ inputs=[search_bar, filter_columns_size, w10_min, w10_max],
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