Clémentine commited on
Commit
ef5b51c
1 Parent(s): 5140860

fix model search

Browse files
app.py CHANGED
@@ -224,7 +224,6 @@ def change_tab(query_param: str):
224
  # Searching and filtering
225
  def update_table(
226
  hidden_df: pd.DataFrame,
227
- current_columns_df: pd.DataFrame,
228
  columns: list,
229
  type_query: list,
230
  precision_query: str,
@@ -233,16 +232,7 @@ def update_table(
233
  query: str,
234
  ):
235
  filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, show_deleted)
236
- final_df = []
237
- if query != "":
238
- queries = query.split(";")
239
- for _q in queries:
240
- if _q != "":
241
- temp_filtered_df = search_table(filtered_df, _q)
242
- if len(temp_filtered_df) > 0:
243
- final_df.append(temp_filtered_df)
244
- if len(final_df) > 0:
245
- filtered_df = pd.concat(final_df).drop_duplicates()
246
  df = select_columns(filtered_df, columns)
247
  return df
248
 
@@ -250,7 +240,6 @@ def update_table(
250
  def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
251
  return df[(df[AutoEvalColumn.dummy.name].str.contains(query, case=False))]
252
 
253
-
254
  def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
255
  always_here_cols = [
256
  AutoEvalColumn.model_type_symbol.name,
@@ -274,6 +263,23 @@ NUMERIC_INTERVALS = {
274
  }
275
 
276
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  def filter_models(
278
  df: pd.DataFrame, type_query: list, size_query: list, precision_query: list, show_deleted: bool
279
  ) -> pd.DataFrame:
@@ -409,7 +415,6 @@ with demo:
409
  update_table,
410
  [
411
  hidden_leaderboard_table_for_search,
412
- leaderboard_table,
413
  shown_columns,
414
  filter_columns_type,
415
  filter_columns_precision,
@@ -423,7 +428,6 @@ with demo:
423
  update_table,
424
  [
425
  hidden_leaderboard_table_for_search,
426
- leaderboard_table,
427
  shown_columns,
428
  filter_columns_type,
429
  filter_columns_precision,
@@ -438,7 +442,6 @@ with demo:
438
  update_table,
439
  [
440
  hidden_leaderboard_table_for_search,
441
- leaderboard_table,
442
  shown_columns,
443
  filter_columns_type,
444
  filter_columns_precision,
@@ -453,7 +456,6 @@ with demo:
453
  update_table,
454
  [
455
  hidden_leaderboard_table_for_search,
456
- leaderboard_table,
457
  shown_columns,
458
  filter_columns_type,
459
  filter_columns_precision,
@@ -468,7 +470,6 @@ with demo:
468
  update_table,
469
  [
470
  hidden_leaderboard_table_for_search,
471
- leaderboard_table,
472
  shown_columns,
473
  filter_columns_type,
474
  filter_columns_precision,
@@ -483,7 +484,6 @@ with demo:
483
  update_table,
484
  [
485
  hidden_leaderboard_table_for_search,
486
- leaderboard_table,
487
  shown_columns,
488
  filter_columns_type,
489
  filter_columns_precision,
 
224
  # Searching and filtering
225
  def update_table(
226
  hidden_df: pd.DataFrame,
 
227
  columns: list,
228
  type_query: list,
229
  precision_query: str,
 
232
  query: str,
233
  ):
234
  filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, show_deleted)
235
+ filtered_df = filter_queries(query, filtered_df)
 
 
 
 
 
 
 
 
 
236
  df = select_columns(filtered_df, columns)
237
  return df
238
 
 
240
  def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
241
  return df[(df[AutoEvalColumn.dummy.name].str.contains(query, case=False))]
242
 
 
243
  def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
244
  always_here_cols = [
245
  AutoEvalColumn.model_type_symbol.name,
 
263
  }
264
 
265
 
266
+ def filter_queries(query: str, filtered_df: pd.DataFrame):
267
+ """Added by Abishek"""
268
+ final_df = []
269
+ if query != "":
270
+ queries = [q.strip() for q in query.split(";")]
271
+ for _q in queries:
272
+ _q = _q.strip()
273
+ if _q != "":
274
+ temp_filtered_df = search_table(filtered_df, _q)
275
+ if len(temp_filtered_df) > 0:
276
+ final_df.append(temp_filtered_df)
277
+ if len(final_df) > 0:
278
+ filtered_df = pd.concat(final_df)
279
+ filtered_df = filtered_df.drop_duplicates(subset=[AutoEvalColumn.model.name, AutoEvalColumn.precision.name, AutoEvalColumn.revision.name])
280
+
281
+ return filtered_df
282
+
283
  def filter_models(
284
  df: pd.DataFrame, type_query: list, size_query: list, precision_query: list, show_deleted: bool
285
  ) -> pd.DataFrame:
 
415
  update_table,
416
  [
417
  hidden_leaderboard_table_for_search,
 
418
  shown_columns,
419
  filter_columns_type,
420
  filter_columns_precision,
 
428
  update_table,
429
  [
430
  hidden_leaderboard_table_for_search,
 
431
  shown_columns,
432
  filter_columns_type,
433
  filter_columns_precision,
 
442
  update_table,
443
  [
444
  hidden_leaderboard_table_for_search,
 
445
  shown_columns,
446
  filter_columns_type,
447
  filter_columns_precision,
 
456
  update_table,
457
  [
458
  hidden_leaderboard_table_for_search,
 
459
  shown_columns,
460
  filter_columns_type,
461
  filter_columns_precision,
 
470
  update_table,
471
  [
472
  hidden_leaderboard_table_for_search,
 
473
  shown_columns,
474
  filter_columns_type,
475
  filter_columns_precision,
 
484
  update_table,
485
  [
486
  hidden_leaderboard_table_for_search,
 
487
  shown_columns,
488
  filter_columns_type,
489
  filter_columns_precision,
model_info_cache.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:8fcaa2a3e1ac6a5559471547af5de4e3ccd49673ad5525890726e65cd90cfe62
3
- size 3620752
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:94e311e2414e80b8eb5e50844c2e79daa4bd3bb6be516fc2448bd05242d125f9
3
+ size 3656702
model_size_cache.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:75d1f64589459eb64e3a50987bf05ed3656248102d1fe2f6c98a008020945840
3
- size 74321
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4aedc91b51cf257cbe3e26a1fdd99e19250bacfa619a64dd85e67d4ff383130f
3
+ size 75455
src/display_models/get_model_metadata.py CHANGED
@@ -40,7 +40,7 @@ def get_model_infos_from_hub(leaderboard_data: List[dict]):
40
  try:
41
  model_info = api.model_info(model_name)
42
  model_info_cache[model_name] = model_info
43
- except huggingface_hub.utils._errors.RepositoryNotFoundError:
44
  print("Repo not found!", model_name)
45
  model_data[AutoEvalColumn.license.name] = None
46
  model_data[AutoEvalColumn.likes.name] = None
 
40
  try:
41
  model_info = api.model_info(model_name)
42
  model_info_cache[model_name] = model_info
43
+ except (huggingface_hub.utils._errors.RepositoryNotFoundError, huggingface_hub.utils._errors.HfHubHTTPError):
44
  print("Repo not found!", model_name)
45
  model_data[AutoEvalColumn.license.name] = None
46
  model_data[AutoEvalColumn.likes.name] = None