Clémentine commited on
Commit
3ae1b8c
1 Parent(s): cd67f11

Now checkboxes for model filters selections

Browse files
Files changed (1) hide show
  1. app.py +27 -35
app.py CHANGED
@@ -231,9 +231,17 @@ def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
231
  ]
232
  return filtered_df
233
 
 
 
 
 
 
 
 
 
234
 
235
  def filter_models(
236
- df: pd.DataFrame, current_columns_df: pd.DataFrame, type_query: str, size_query: str, show_deleted: bool
237
  ) -> pd.DataFrame:
238
  current_columns = current_columns_df.columns
239
 
@@ -243,24 +251,12 @@ def filter_models(
243
  else: # Show only still on the hub models
244
  filtered_df = df[df[AutoEvalColumn.still_on_hub.name] == True][current_columns]
245
 
246
- if type_query != "all":
247
- type_emoji = type_query[0]
248
- filtered_df = filtered_df[df[AutoEvalColumn.model_type_symbol.name] == type_emoji]
249
-
250
- if size_query != "all":
251
- numeric_intervals = {
252
- "all": (0, 10000),
253
- "< 1B": (0, 1),
254
- "~3B": (1, 5),
255
- "~7B": (6, 11),
256
- "~13B": (12, 15),
257
- "~35B": (16, 55),
258
- "60B+": (55, 10000),
259
- }
260
- numeric_interval = numeric_intervals[size_query]
261
- params_column = pd.to_numeric(df[AutoEvalColumn.params.name], errors="coerce")
262
-
263
- filtered_df = filtered_df[params_column.between(*numeric_interval)]
264
 
265
  return filtered_df
266
 
@@ -313,31 +309,27 @@ with demo:
313
  elem_id="search-bar",
314
  )
315
  with gr.Box(elem_id="box-filter"):
316
- filter_columns_type = gr.Radio(
317
- label=" Filter model types",
318
  choices=[
319
- "all",
320
  ModelType.PT.to_str(),
321
  ModelType.FT.to_str(),
322
  ModelType.IFT.to_str(),
323
  ModelType.RL.to_str(),
324
  ],
325
- value="all",
 
 
 
 
 
326
  interactive=True,
327
  elem_id="filter-columns-type",
328
  )
329
- filter_columns_size = gr.Radio(
330
- label=" Filter model sizes",
331
- choices=[
332
- "all",
333
- "< 1B",
334
- "~3B",
335
- "~7B",
336
- "~13B",
337
- "~35B",
338
- "60B+",
339
- ],
340
- value="all",
341
  interactive=True,
342
  elem_id="filter-columns-size",
343
  )
 
231
  ]
232
  return filtered_df
233
 
234
+ NUMERIC_INTERVALS = {
235
+ "< 1.5B": (0, 1.5),
236
+ "~3B": (1.5, 5),
237
+ "~7B": (6, 11),
238
+ "~13B": (12, 15),
239
+ "~35B": (16, 55),
240
+ "60B+": (55, 10000),
241
+ }
242
 
243
  def filter_models(
244
+ df: pd.DataFrame, current_columns_df: pd.DataFrame, type_query: list, size_query: list, show_deleted: bool
245
  ) -> pd.DataFrame:
246
  current_columns = current_columns_df.columns
247
 
 
251
  else: # Show only still on the hub models
252
  filtered_df = df[df[AutoEvalColumn.still_on_hub.name] == True][current_columns]
253
 
254
+ type_emoji = [t[0] for t in type_query]
255
+ filtered_df = filtered_df[df[AutoEvalColumn.model_type_symbol.name].isin(type_emoji)]
256
+
257
+ numeric_interval = [NUMERIC_INTERVALS[s] for s in size_query]
258
+ params_column = pd.to_numeric(df[AutoEvalColumn.params.name], errors="coerce")
259
+ filtered_df = filtered_df[params_column.between(numeric_interval[0][0], numeric_interval[-1][-1])]
 
 
 
 
 
 
 
 
 
 
 
 
260
 
261
  return filtered_df
262
 
 
309
  elem_id="search-bar",
310
  )
311
  with gr.Box(elem_id="box-filter"):
312
+ filter_columns_type = gr.CheckboxGroup(
313
+ label="Model types",
314
  choices=[
 
315
  ModelType.PT.to_str(),
316
  ModelType.FT.to_str(),
317
  ModelType.IFT.to_str(),
318
  ModelType.RL.to_str(),
319
  ],
320
+ value=[
321
+ ModelType.PT.to_str(),
322
+ ModelType.FT.to_str(),
323
+ ModelType.IFT.to_str(),
324
+ ModelType.RL.to_str(),
325
+ ],
326
  interactive=True,
327
  elem_id="filter-columns-type",
328
  )
329
+ filter_columns_size = gr.CheckboxGroup(
330
+ label="Model sizes",
331
+ choices=list(NUMERIC_INTERVALS.keys()),
332
+ value=list(NUMERIC_INTERVALS.keys()),
 
 
 
 
 
 
 
 
333
  interactive=True,
334
  elem_id="filter-columns-size",
335
  )