DontPlanToEnd
commited on
Commit
β’
fb6ea92
1
Parent(s):
890d28f
Update app.py
Browse files
app.py
CHANGED
@@ -110,34 +110,34 @@ def load_leaderboard_data(csv_file_path):
|
|
110 |
return pd.DataFrame(columns=UGI_COLS + WRITING_STYLE_COLS + ANIME_RATING_COLS + ADDITIONAL_COLS)
|
111 |
|
112 |
# Update the leaderboard table based on the search query and parameter range filters
|
113 |
-
def update_table(df, query, param_ranges, is_foundation, columns, w10_range, additional_cols):
|
114 |
mask = pd.Series(True, index=df.index)
|
115 |
|
116 |
# Apply model size filter
|
117 |
if param_ranges:
|
118 |
-
size_mask = pd.Series(False, index=
|
119 |
for param_range in param_ranges:
|
120 |
if param_range == '~2':
|
121 |
-
size_mask |= (
|
122 |
elif param_range == '~4':
|
123 |
-
size_mask |= ((
|
124 |
elif param_range == '~8':
|
125 |
-
size_mask |= ((
|
126 |
elif param_range == '~13':
|
127 |
-
size_mask |= ((
|
128 |
elif param_range == '~20':
|
129 |
-
size_mask |= ((
|
130 |
elif param_range == '~34':
|
131 |
-
size_mask |= ((
|
132 |
elif param_range == '~50':
|
133 |
-
size_mask |= ((
|
134 |
elif param_range == '~70+':
|
135 |
-
size_mask |= (
|
136 |
elif param_range == 'Closed':
|
137 |
-
size_mask |=
|
138 |
-
filtered_df = filtered_df[size_mask]
|
139 |
mask &= size_mask
|
140 |
|
|
|
141 |
if is_foundation:
|
142 |
mask &= df['Foundation'] == 1
|
143 |
|
@@ -145,6 +145,7 @@ def update_table(df, query, param_ranges, is_foundation, columns, w10_range, add
|
|
145 |
escaped_query = re.escape(query)
|
146 |
mask &= df['Model'].str.contains(escaped_query, case=False, na=False, regex=True)
|
147 |
|
|
|
148 |
if 'W/10 π' in df.columns:
|
149 |
mask &= (df['W/10 π'] >= w10_range[0]) & (df['W/10 π'] <= w10_range[1])
|
150 |
|
|
|
110 |
return pd.DataFrame(columns=UGI_COLS + WRITING_STYLE_COLS + ANIME_RATING_COLS + ADDITIONAL_COLS)
|
111 |
|
112 |
# Update the leaderboard table based on the search query and parameter range filters
|
113 |
+
def update_table(df: pd.DataFrame, query: str, param_ranges: list, is_foundation: bool, columns: list, w10_range: tuple, additional_cols: list) -> pd.DataFrame:
|
114 |
mask = pd.Series(True, index=df.index)
|
115 |
|
116 |
# Apply model size filter
|
117 |
if param_ranges:
|
118 |
+
size_mask = pd.Series(False, index=df.index)
|
119 |
for param_range in param_ranges:
|
120 |
if param_range == '~2':
|
121 |
+
size_mask |= (df['Total Params'] < 2.5)
|
122 |
elif param_range == '~4':
|
123 |
+
size_mask |= ((df['Total Params'] >= 2.5) & (df['Total Params'] < 6))
|
124 |
elif param_range == '~8':
|
125 |
+
size_mask |= ((df['Total Params'] >= 6) & (df['Total Params'] < 9.5))
|
126 |
elif param_range == '~13':
|
127 |
+
size_mask |= ((df['Total Params'] >= 9.5) & (df['Total Params'] < 16))
|
128 |
elif param_range == '~20':
|
129 |
+
size_mask |= ((df['Total Params'] >= 16) & (df['Total Params'] < 28))
|
130 |
elif param_range == '~34':
|
131 |
+
size_mask |= ((df['Total Params'] >= 28) & (df['Total Params'] < 40))
|
132 |
elif param_range == '~50':
|
133 |
+
size_mask |= ((df['Total Params'] >= 40) & (df['Total Params'] < 65))
|
134 |
elif param_range == '~70+':
|
135 |
+
size_mask |= (df['Total Params'] >= 65)
|
136 |
elif param_range == 'Closed':
|
137 |
+
size_mask |= df['Total Params'].isna()
|
|
|
138 |
mask &= size_mask
|
139 |
|
140 |
+
# Apply foundation model filter
|
141 |
if is_foundation:
|
142 |
mask &= df['Foundation'] == 1
|
143 |
|
|
|
145 |
escaped_query = re.escape(query)
|
146 |
mask &= df['Model'].str.contains(escaped_query, case=False, na=False, regex=True)
|
147 |
|
148 |
+
# Apply W/10 filtering
|
149 |
if 'W/10 π' in df.columns:
|
150 |
mask &= (df['W/10 π'] >= w10_range[0]) & (df['W/10 π'] <= w10_range[1])
|
151 |
|