Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update utils.py
Browse files
utils.py
CHANGED
@@ -142,39 +142,36 @@ def refresh_data():
|
|
142 |
df = get_df()
|
143 |
return df[COLUMN_NAMES]
|
144 |
|
145 |
-
# def refresh_data():
|
146 |
-
# df = get_df()
|
147 |
-
# min_size, max_size = get_size_range(df)
|
148 |
-
# filtered_df = search_and_filter_models(df, "", min_size, max_size)
|
149 |
-
# return filtered_df[COLUMN_NAMES]
|
150 |
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
|
156 |
-
|
157 |
-
# size_filtered = df[numeric_mask &
|
158 |
-
# (df['Model Size(B)'] >= min_size) &
|
159 |
-
# (df['Model Size(B)'] <= max_size)]
|
160 |
-
# unknown_entries = df[df['Model Size(B)'] == 'unknown']
|
161 |
|
162 |
-
|
163 |
|
164 |
-
def search_and_filter_models(df, query, min_size, max_size):
|
165 |
-
filtered_df = df.copy()
|
166 |
|
167 |
-
|
168 |
-
|
|
|
|
|
|
|
169 |
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
|
175 |
-
|
176 |
|
177 |
-
|
178 |
|
179 |
|
180 |
def search_models(df, query):
|
@@ -183,11 +180,16 @@ def search_models(df, query):
|
|
183 |
return df
|
184 |
|
185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
def get_size_range(df):
|
187 |
-
|
188 |
-
|
189 |
-
return float(numeric_sizes.min()), float(numeric_sizes.max())
|
190 |
-
return 0, 1000
|
191 |
|
192 |
|
193 |
def process_model_size(size):
|
|
|
142 |
df = get_df()
|
143 |
return df[COLUMN_NAMES]
|
144 |
|
|
|
|
|
|
|
|
|
|
|
145 |
|
146 |
+
def search_and_filter_models(df, query, min_size, max_size):
|
147 |
+
filtered_df = df.copy()
|
148 |
+
|
149 |
+
if query:
|
150 |
+
filtered_df = filtered_df[filtered_df['Models'].str.contains(query, case=False, na=False)]
|
151 |
|
152 |
+
size_mask = filtered_df['Model Size(B)'].apply(lambda x:
|
153 |
+
(min_size <= 1000.0 <= max_size) if x == 'unknown'
|
154 |
+
else (min_size <= x <= max_size))
|
155 |
|
156 |
+
filtered_df = filtered_df[size_mask]
|
|
|
|
|
|
|
|
|
157 |
|
158 |
+
return filtered_df[COLUMN_NAMES]
|
159 |
|
|
|
|
|
160 |
|
161 |
+
# def search_and_filter_models(df, query, min_size, max_size):
|
162 |
+
# filtered_df = df.copy()
|
163 |
+
|
164 |
+
# if query:
|
165 |
+
# filtered_df = filtered_df[filtered_df['Models'].str.contains(query, case=False, na=False)]
|
166 |
|
167 |
+
# def size_filter(x):
|
168 |
+
# if isinstance(x, (int, float)):
|
169 |
+
# return min_size <= x <= max_size
|
170 |
+
# return True
|
171 |
|
172 |
+
# filtered_df = filtered_df[filtered_df['Model Size(B)'].apply(size_filter)]
|
173 |
|
174 |
+
# return filtered_df[COLUMN_NAMES]
|
175 |
|
176 |
|
177 |
def search_models(df, query):
|
|
|
180 |
return df
|
181 |
|
182 |
|
183 |
+
# def get_size_range(df):
|
184 |
+
# numeric_sizes = df[df['Model Size(B)'].apply(lambda x: isinstance(x, (int, float)))]['Model Size(B)']
|
185 |
+
# if len(numeric_sizes) > 0:
|
186 |
+
# return float(numeric_sizes.min()), float(numeric_sizes.max())
|
187 |
+
# return 0, 1000
|
188 |
+
|
189 |
+
|
190 |
def get_size_range(df):
|
191 |
+
sizes = df['Model Size(B)'].apply(lambda x: 1000.0 if x == 'unknown' else x)
|
192 |
+
return float(sizes.min()), float(sizes.max())
|
|
|
|
|
193 |
|
194 |
|
195 |
def process_model_size(size):
|