sh1gechan commited on
Commit
3437d98
1 Parent(s): 63ec9f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -11
app.py CHANGED
@@ -53,6 +53,9 @@ except Exception:
53
  restart_space()
54
 
55
  LEADERBOARD_DF = get_leaderboard_df(EVAL_RESULTS_PATH, EVAL_REQUESTS_PATH, COLS, BENCHMARK_COLS)
 
 
 
56
  original_df = LEADERBOARD_DF
57
  leaderboard_df = original_df.copy()
58
  (
@@ -76,12 +79,23 @@ def update_table(
76
  show_flagged: bool,
77
  query: str,
78
  ):
 
 
 
79
  filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, add_special_tokens_query, num_few_shots_query, show_deleted, show_merges, show_flagged)
 
 
80
  filtered_df = filter_queries(query, filtered_df)
 
 
81
  print(f"Filter applied: query={query}, columns={columns}, type_query={type_query}, precision_query={precision_query}")
82
- print(filtered_df.head()) # フィルタ後のデータを確認
 
83
 
84
  df = select_columns(filtered_df, columns)
 
 
 
85
  return df
86
 
87
 
@@ -129,29 +143,37 @@ def filter_queries(query: str, filtered_df: pd.DataFrame):
129
  def filter_models(
130
  df: pd.DataFrame, type_query: list, size_query: list, precision_query: list, add_special_tokens_query: list, num_few_shots_query: list, show_deleted: bool, show_merges: bool, show_flagged: bool
131
  ) -> pd.DataFrame:
132
- # Show all models
 
 
 
133
  if show_deleted:
134
  filtered_df = df
135
- else: # Show only still on the hub models
136
  filtered_df = df[df[AutoEvalColumn.still_on_hub.name] == True]
137
-
138
- #if not show_merges:
139
- # filtered_df = filtered_df[filtered_df[AutoEvalColumn.merged.name] == False]
140
-
141
- #if not show_flagged:
142
- # filtered_df = filtered_df[filtered_df[AutoEvalColumn.flagged.name] == False]
143
 
144
  type_emoji = [t[0] for t in type_query]
145
  filtered_df = filtered_df.loc[df[AutoEvalColumn.model_type_symbol.name].isin(type_emoji)]
 
 
146
  filtered_df = filtered_df.loc[df[AutoEvalColumn.precision.name].isin(precision_query + ["None"])]
 
 
147
  filtered_df = filtered_df.loc[df[AutoEvalColumn.add_special_tokens.name].isin(add_special_tokens_query)]
 
 
148
  filtered_df = filtered_df.loc[df[AutoEvalColumn.num_few_shots.name].isin(num_few_shots_query)]
149
-
150
 
151
  numeric_interval = pd.IntervalIndex(sorted([NUMERIC_INTERVALS[s] for s in size_query]))
152
  params_column = pd.to_numeric(df[AutoEvalColumn.params.name], errors="coerce")
153
  mask = params_column.apply(lambda x: any(numeric_interval.contains(x)))
154
  filtered_df = filtered_df.loc[mask]
 
 
 
 
155
  return filtered_df
156
 
157
  leaderboard_df = filter_models(leaderboard_df, [t.to_str(" : ") for t in ModelType], list(NUMERIC_INTERVALS.keys()), [i.value.name for i in Precision], [i.value.name for i in AddSpecialTokens], [i.value.name for i in NumFewShots], False, False, False)
@@ -248,7 +270,9 @@ with demo:
248
  visible=True,
249
  #column_widths=["2%", "33%"]
250
  )
251
- print(leaderboard_df.head()) # リーダーボードテーブルに渡される前のデータを確認
 
 
252
 
253
  # Dummy leaderboard for handling the case when the user uses backspace key
254
  hidden_leaderboard_table_for_search = gr.components.Dataframe(
 
53
  restart_space()
54
 
55
  LEADERBOARD_DF = get_leaderboard_df(EVAL_RESULTS_PATH, EVAL_REQUESTS_PATH, COLS, BENCHMARK_COLS)
56
+ print("Initial LEADERBOARD_DF:")
57
+ print(LEADERBOARD_DF.head())
58
+ print(f"LEADERBOARD_DF shape: {LEADERBOARD_DF.shape}")
59
  original_df = LEADERBOARD_DF
60
  leaderboard_df = original_df.copy()
61
  (
 
79
  show_flagged: bool,
80
  query: str,
81
  ):
82
+ print(f"Update table called with: type_query={type_query}, precision_query={precision_query}, size_query={size_query}")
83
+ print(f"hidden_df shape before filtering: {hidden_df.shape}")
84
+
85
  filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, add_special_tokens_query, num_few_shots_query, show_deleted, show_merges, show_flagged)
86
+ print(f"filtered_df shape after filter_models: {filtered_df.shape}")
87
+
88
  filtered_df = filter_queries(query, filtered_df)
89
+ print(f"filtered_df shape after filter_queries: {filtered_df.shape}")
90
+
91
  print(f"Filter applied: query={query}, columns={columns}, type_query={type_query}, precision_query={precision_query}")
92
+ print("Filtered dataframe head:")
93
+ print(filtered_df.head())
94
 
95
  df = select_columns(filtered_df, columns)
96
+ print(f"Final df shape: {df.shape}")
97
+ print("Final dataframe head:")
98
+ print(df.head())
99
  return df
100
 
101
 
 
143
  def filter_models(
144
  df: pd.DataFrame, type_query: list, size_query: list, precision_query: list, add_special_tokens_query: list, num_few_shots_query: list, show_deleted: bool, show_merges: bool, show_flagged: bool
145
  ) -> pd.DataFrame:
146
+ print(f"filter_models called with: type_query={type_query}, size_query={size_query}, precision_query={precision_query}")
147
+ print(f"Initial df shape: {df.shape}")
148
+
149
+ # 各フィルタリング操作の後にprint文を追加
150
  if show_deleted:
151
  filtered_df = df
152
+ else:
153
  filtered_df = df[df[AutoEvalColumn.still_on_hub.name] == True]
154
+ print(f"After deletion filter: {filtered_df.shape}")
 
 
 
 
 
155
 
156
  type_emoji = [t[0] for t in type_query]
157
  filtered_df = filtered_df.loc[df[AutoEvalColumn.model_type_symbol.name].isin(type_emoji)]
158
+ print(f"After type filter: {filtered_df.shape}")
159
+
160
  filtered_df = filtered_df.loc[df[AutoEvalColumn.precision.name].isin(precision_query + ["None"])]
161
+ print(f"After precision filter: {filtered_df.shape}")
162
+
163
  filtered_df = filtered_df.loc[df[AutoEvalColumn.add_special_tokens.name].isin(add_special_tokens_query)]
164
+ print(f"After add_special_tokens filter: {filtered_df.shape}")
165
+
166
  filtered_df = filtered_df.loc[df[AutoEvalColumn.num_few_shots.name].isin(num_few_shots_query)]
167
+ print(f"After num_few_shots filter: {filtered_df.shape}")
168
 
169
  numeric_interval = pd.IntervalIndex(sorted([NUMERIC_INTERVALS[s] for s in size_query]))
170
  params_column = pd.to_numeric(df[AutoEvalColumn.params.name], errors="coerce")
171
  mask = params_column.apply(lambda x: any(numeric_interval.contains(x)))
172
  filtered_df = filtered_df.loc[mask]
173
+ print(f"After size filter: {filtered_df.shape}")
174
+
175
+ print("Filtered dataframe head:")
176
+ print(filtered_df.head())
177
  return filtered_df
178
 
179
  leaderboard_df = filter_models(leaderboard_df, [t.to_str(" : ") for t in ModelType], list(NUMERIC_INTERVALS.keys()), [i.value.name for i in Precision], [i.value.name for i in AddSpecialTokens], [i.value.name for i in NumFewShots], False, False, False)
 
270
  visible=True,
271
  #column_widths=["2%", "33%"]
272
  )
273
+ print("Leaderboard table initial value:")
274
+ print(leaderboard_table.value.head())
275
+ print(f"Leaderboard table shape: {leaderboard_table.value.shape}")
276
 
277
  # Dummy leaderboard for handling the case when the user uses backspace key
278
  hidden_leaderboard_table_for_search = gr.components.Dataframe(