sh1gechan commited on
Commit
bbdb195
1 Parent(s): 87f7dc5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -33
app.py CHANGED
@@ -143,43 +143,37 @@ def filter_queries(query: str, filtered_df: pd.DataFrame):
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"Initial df shape: {df.shape}")
147
- print(f"Initial df columns: {df.columns}")
148
  print(f"Initial df content:\n{df}")
149
-
150
- filtered_df = df
151
 
152
- # モデルタイプでフィルタリング
153
- type_emoji = [t.split()[0] for t in type_query]
154
- filtered_df = filtered_df[filtered_df[AutoEvalColumn.model_type_symbol.name].isin(type_emoji + ["?"])]
 
155
  print(f"After type filter: {filtered_df.shape}")
 
156
 
157
- # Precisionでフィルタリング
158
- filtered_df = filtered_df[filtered_df[AutoEvalColumn.precision.name].isin(precision_query + ["None", "Unknown", "?"])]
159
  print(f"After precision filter: {filtered_df.shape}")
 
160
 
161
- # Add Special Tokensでフィルタリング
162
- filtered_df = filtered_df[filtered_df[AutoEvalColumn.add_special_tokens.name].isin(add_special_tokens_query + ["Unknown", "?"])]
163
  print(f"After add_special_tokens filter: {filtered_df.shape}")
 
164
 
165
- # Num Few Shotsでフィルタリング
166
- filtered_df = filtered_df[filtered_df[AutoEvalColumn.num_few_shots.name].isin(num_few_shots_query + ["Unknown", "?"])]
167
  print(f"After num_few_shots filter: {filtered_df.shape}")
 
168
 
169
- # モデルサイズでフィルタリング
170
- if "Unknown" in size_query:
171
- size_mask = filtered_df[AutoEvalColumn.params.name].isna() | (filtered_df[AutoEvalColumn.params.name].astype(str).isin(["Unknown", "?"]))
172
- else:
173
- numeric_interval = pd.IntervalIndex(sorted([NUMERIC_INTERVALS[s] for s in size_query if s != "Unknown"]))
174
- params_column = pd.to_numeric(filtered_df[AutoEvalColumn.params.name], errors="coerce")
175
- size_mask = params_column.apply(lambda x: any(numeric_interval.contains(x)) if pd.notnull(x) else False)
176
-
177
- filtered_df = filtered_df[size_mask]
178
  print(f"After size filter: {filtered_df.shape}")
 
179
 
180
- print("Filtered dataframe head:")
181
- print(filtered_df.head())
182
- print(f"Filtered df columns: {filtered_df.columns}")
183
  return filtered_df
184
 
185
  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)
@@ -263,22 +257,19 @@ with demo:
263
  elem_id="filter-columns-num-few-shots",
264
  )
265
 
266
- leaderboard_df_filtered = 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)
267
 
268
- # 列名の重複を解消
269
- leaderboard_df_filtered.columns = pd.io.parsers.base._maybe_dedup_names(leaderboard_df_filtered.columns)
270
-
271
  leaderboard_table = gr.components.Dataframe(
272
- value=leaderboard_df_filtered.to_dict('records'),
273
- headers=list(leaderboard_df_filtered.columns),
274
- datatype={col: "str" for col in leaderboard_df_filtered.columns},
275
  elem_id="leaderboard-table",
276
  interactive=False,
277
  visible=True,
278
  )
279
  print("Leaderboard table initial value:")
280
- print(leaderboard_df_filtered)
281
- print(f"Leaderboard table shape: {leaderboard_df_filtered.shape}")
282
 
283
  # Dummy leaderboard for handling the case when the user uses backspace key
284
  hidden_leaderboard_table_for_search = gr.components.Dataframe(
 
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}, add_special_tokens_query={add_special_tokens_query}, num_few_shots_query={num_few_shots_query}")
147
  print(f"Initial df shape: {df.shape}")
 
148
  print(f"Initial df content:\n{df}")
 
 
149
 
150
+ filtered_df = df
151
+
152
+ # type_emoji = [t[0] for t in type_query]
153
+ # filtered_df = filtered_df[filtered_df[AutoEvalColumn.model_type_symbol.name].isin(type_emoji)]
154
  print(f"After type filter: {filtered_df.shape}")
155
+ print(f"After type filter content:\n{filtered_df}")
156
 
157
+ # Precision filterをコメントアウト
158
+ # filtered_df = filtered_df[filtered_df[AutoEvalColumn.precision.name].isin(precision_query + ["None"])]
159
  print(f"After precision filter: {filtered_df.shape}")
160
+ print(f"After precision filter content:\n{filtered_df}")
161
 
162
+ # filtered_df = filtered_df[filtered_df[AutoEvalColumn.add_special_tokens.name].isin(add_special_tokens_query)]
 
163
  print(f"After add_special_tokens filter: {filtered_df.shape}")
164
+ print(f"After add_special_tokens filter content:\n{filtered_df}")
165
 
166
+ # filtered_df = filtered_df[filtered_df[AutoEvalColumn.num_few_shots.name].isin(num_few_shots_query)]
 
167
  print(f"After num_few_shots filter: {filtered_df.shape}")
168
+ print(f"After num_few_shots filter content:\n{filtered_df}")
169
 
170
+ # numeric_interval = pd.IntervalIndex(sorted([NUMERIC_INTERVALS[s] for s in size_query]))
171
+ # params_column = pd.to_numeric(filtered_df[AutoEvalColumn.params.name], errors="coerce")
172
+ # mask = params_column.apply(lambda x: any(numeric_interval.contains(x)))
173
+ # filtered_df = filtered_df.loc[mask]
 
 
 
 
 
174
  print(f"After size filter: {filtered_df.shape}")
175
+ print(f"After size filter content:\n{filtered_df}")
176
 
 
 
 
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)
 
257
  elem_id="filter-columns-num-few-shots",
258
  )
259
 
260
+ leaderboard_df_filtered = 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)
261
 
 
 
 
262
  leaderboard_table = gr.components.Dataframe(
263
+ value=leaderboard_df_filtered,
264
+ headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
265
+ datatype=TYPES,
266
  elem_id="leaderboard-table",
267
  interactive=False,
268
  visible=True,
269
  )
270
  print("Leaderboard table initial value:")
271
+ print(leaderboard_table.value)
272
+ print(f"Leaderboard table shape: {leaderboard_table.value.shape if isinstance(leaderboard_table.value, pd.DataFrame) else 'Not a DataFrame'}")
273
 
274
  # Dummy leaderboard for handling the case when the user uses backspace key
275
  hidden_leaderboard_table_for_search = gr.components.Dataframe(