Tom Aarsen commited on
Commit
2eb890d
1 Parent(s): d81785e

Introduce new intervals: 100M & 250M and 250M & 500M

Browse files
Files changed (1) hide show
  1. app.py +7 -12
app.py CHANGED
@@ -1863,7 +1863,8 @@ def update_url_language(event: gr.SelectData, current_task_language: dict, langu
1863
 
1864
  NUMERIC_INTERVALS = {
1865
  "<100M": pd.Interval(0, 100, closed="right"),
1866
- ">100M, <500M": pd.Interval(100, 500, closed="right"),
 
1867
  ">500M, <1B": pd.Interval(500, 1000, closed="right"),
1868
  ">1B": pd.Interval(1000, 1_000_000, closed="right"),
1869
  }
@@ -1897,17 +1898,11 @@ def filter_data(search_query, model_types, model_sizes, *full_dataframes):
1897
  df = df[reduce(lambda a, b: a | b, masks)]
1898
 
1899
  # Apply the model size filtering
1900
- if model_sizes != ["?", *NUMERIC_INTERVALS.keys()]:
1901
- masks = []
1902
- # Handle the ? only
1903
- if "?" in model_sizes:
1904
- masks.append(df["Model Size (Million Parameters)"] == "")
1905
- model_sizes.remove("?")
1906
- # Handle the numeric intervals only
1907
  numeric_interval = pd.IntervalIndex(sorted([NUMERIC_INTERVALS[model_size] for model_size in model_sizes]))
1908
  sizes = df["Model Size (Million Parameters)"].replace('', 0)
1909
- masks.append(sizes.apply(lambda size: any(numeric_interval.contains(size))))
1910
- df = df[reduce(lambda a, b: a | b, masks)]
1911
 
1912
  output_dataframes.append(df)
1913
  return output_dataframes
@@ -1937,8 +1932,8 @@ with gr.Blocks(css=css) as block:
1937
  )
1938
  filter_model_sizes = gr.CheckboxGroup(
1939
  label="Model sizes (in number of parameters)",
1940
- choices=["?"] + list(NUMERIC_INTERVALS.keys()),
1941
- value=["?"] + list(NUMERIC_INTERVALS.keys()),
1942
  interactive=True,
1943
  elem_classes=["filter-checkbox-group"]
1944
  )
 
1863
 
1864
  NUMERIC_INTERVALS = {
1865
  "<100M": pd.Interval(0, 100, closed="right"),
1866
+ ">100M, <250M": pd.Interval(100, 250, closed="right"),
1867
+ ">250M, <500M": pd.Interval(250, 500, closed="right"),
1868
  ">500M, <1B": pd.Interval(500, 1000, closed="right"),
1869
  ">1B": pd.Interval(1000, 1_000_000, closed="right"),
1870
  }
 
1898
  df = df[reduce(lambda a, b: a | b, masks)]
1899
 
1900
  # Apply the model size filtering
1901
+ if model_sizes != list(NUMERIC_INTERVALS.keys()):
 
 
 
 
 
 
1902
  numeric_interval = pd.IntervalIndex(sorted([NUMERIC_INTERVALS[model_size] for model_size in model_sizes]))
1903
  sizes = df["Model Size (Million Parameters)"].replace('', 0)
1904
+ mask = sizes.apply(lambda size: any(numeric_interval.contains(size)))
1905
+ df = df[mask]
1906
 
1907
  output_dataframes.append(df)
1908
  return output_dataframes
 
1932
  )
1933
  filter_model_sizes = gr.CheckboxGroup(
1934
  label="Model sizes (in number of parameters)",
1935
+ choices=list(NUMERIC_INTERVALS.keys()),
1936
+ value=list(NUMERIC_INTERVALS.keys()),
1937
  interactive=True,
1938
  elem_classes=["filter-checkbox-group"]
1939
  )