Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,7 +28,6 @@ def load_models_data():
|
|
| 28 |
else:
|
| 29 |
df['params'] = -1
|
| 30 |
|
| 31 |
-
# Ensure createdAt is in datetime format, coercing errors
|
| 32 |
if 'createdAt' in df.columns:
|
| 33 |
df['createdAt'] = pd.to_datetime(df['createdAt'], errors='coerce')
|
| 34 |
|
|
@@ -46,7 +45,7 @@ def get_param_range_values(param_range_labels):
|
|
| 46 |
max_val = float('inf') if '>' in max_label else float(max_label.replace('B', ''))
|
| 47 |
return min_val, max_val
|
| 48 |
|
| 49 |
-
def make_treemap_data(df, count_by, top_k=25, tag_filter=None, pipeline_filter=None, param_range=None, skip_orgs=None, include_unknown_param_size=True, created_after_date:
|
| 50 |
if df is None or df.empty: return pd.DataFrame()
|
| 51 |
filtered_df = df.copy()
|
| 52 |
|
|
@@ -65,13 +64,16 @@ def make_treemap_data(df, count_by, top_k=25, tag_filter=None, pipeline_filter=N
|
|
| 65 |
if min_params is not None: filtered_df = filtered_df[filtered_df['params'] >= min_params]
|
| 66 |
if max_params is not None and max_params != float('inf'): filtered_df = filtered_df[filtered_df['params'] < max_params]
|
| 67 |
|
| 68 |
-
# --- CORRECTED DATE FILTER LOGIC FOR
|
| 69 |
if created_after_date is not None and 'createdAt' in filtered_df.columns:
|
| 70 |
-
# Drop rows where 'createdAt' could not be parsed
|
| 71 |
filtered_df = filtered_df.dropna(subset=['createdAt'])
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
| 73 |
# Compare its date part with the date part of the 'createdAt' column.
|
| 74 |
-
filtered_df = filtered_df[filtered_df['createdAt'].dt.date >
|
| 75 |
|
| 76 |
if skip_orgs and len(skip_orgs) > 0 and "organization" in filtered_df.columns:
|
| 77 |
filtered_df = filtered_df[~filtered_df["organization"].isin(skip_orgs)]
|
|
@@ -131,7 +133,6 @@ with gr.Blocks(title="🤗 ModelVerse Explorer", fill_width=True, css=custom_css
|
|
| 131 |
param_range_display = gr.Markdown(f"Range: `{PARAM_CHOICES[0]}` to `{PARAM_CHOICES[-1]}`")
|
| 132 |
include_unknown_params_checkbox = gr.Checkbox(label="Include models with unknown parameter size", value=True)
|
| 133 |
|
| 134 |
-
# --- CORRECTED COMPONENT BASED ON DOCUMENTATION ---
|
| 135 |
created_after_datepicker = gr.DateTime(label="Created After")
|
| 136 |
|
| 137 |
top_k_dropdown = gr.Dropdown(label="Number of Top Organizations", choices=TOP_K_CHOICES, value=25)
|
|
@@ -190,7 +191,7 @@ with gr.Blocks(title="🤗 ModelVerse Explorer", fill_width=True, css=custom_css
|
|
| 190 |
"downloads", "None", None, None, PARAM_CHOICES_DEFAULT_INDICES, 25,
|
| 191 |
"TheBloke,MaziyarPanahi,unsloth,modularai,Gensyn,bartowski", True, None, current_df, progress
|
| 192 |
)
|
| 193 |
-
return
|
| 194 |
|
| 195 |
def ui_generate_plot_controller(metric_choice, filter_type, tag_choice, pipeline_choice,
|
| 196 |
param_range_indices, k_orgs, skip_orgs_input, include_unknown_param_size_flag,
|
|
@@ -229,4 +230,4 @@ with gr.Blocks(title="🤗 ModelVerse Explorer", fill_width=True, css=custom_css
|
|
| 229 |
|
| 230 |
if __name__ == "__main__":
|
| 231 |
print(f"Application starting...")
|
| 232 |
-
demo.queue().launch()
|
|
|
|
| 28 |
else:
|
| 29 |
df['params'] = -1
|
| 30 |
|
|
|
|
| 31 |
if 'createdAt' in df.columns:
|
| 32 |
df['createdAt'] = pd.to_datetime(df['createdAt'], errors='coerce')
|
| 33 |
|
|
|
|
| 45 |
max_val = float('inf') if '>' in max_label else float(max_label.replace('B', ''))
|
| 46 |
return min_val, max_val
|
| 47 |
|
| 48 |
+
def make_treemap_data(df, count_by, top_k=25, tag_filter=None, pipeline_filter=None, param_range=None, skip_orgs=None, include_unknown_param_size=True, created_after_date: float = None):
|
| 49 |
if df is None or df.empty: return pd.DataFrame()
|
| 50 |
filtered_df = df.copy()
|
| 51 |
|
|
|
|
| 64 |
if min_params is not None: filtered_df = filtered_df[filtered_df['params'] >= min_params]
|
| 65 |
if max_params is not None and max_params != float('inf'): filtered_df = filtered_df[filtered_df['params'] < max_params]
|
| 66 |
|
| 67 |
+
# --- CORRECTED DATE FILTER LOGIC FOR FLOAT TIMESTAMP ---
|
| 68 |
if created_after_date is not None and 'createdAt' in filtered_df.columns:
|
| 69 |
+
# Drop rows where 'createdAt' could not be parsed to avoid errors
|
| 70 |
filtered_df = filtered_df.dropna(subset=['createdAt'])
|
| 71 |
+
|
| 72 |
+
# Convert the Unix timestamp (float) from the UI into a Python date object
|
| 73 |
+
filter_date = datetime.datetime.fromtimestamp(created_after_date).date()
|
| 74 |
+
|
| 75 |
# Compare its date part with the date part of the 'createdAt' column.
|
| 76 |
+
filtered_df = filtered_df[filtered_df['createdAt'].dt.date > filter_date]
|
| 77 |
|
| 78 |
if skip_orgs and len(skip_orgs) > 0 and "organization" in filtered_df.columns:
|
| 79 |
filtered_df = filtered_df[~filtered_df["organization"].isin(skip_orgs)]
|
|
|
|
| 133 |
param_range_display = gr.Markdown(f"Range: `{PARAM_CHOICES[0]}` to `{PARAM_CHOICES[-1]}`")
|
| 134 |
include_unknown_params_checkbox = gr.Checkbox(label="Include models with unknown parameter size", value=True)
|
| 135 |
|
|
|
|
| 136 |
created_after_datepicker = gr.DateTime(label="Created After")
|
| 137 |
|
| 138 |
top_k_dropdown = gr.Dropdown(label="Number of Top Organizations", choices=TOP_K_CHOICES, value=25)
|
|
|
|
| 191 |
"downloads", "None", None, None, PARAM_CHOICES_DEFAULT_INDICES, 25,
|
| 192 |
"TheBloke,MaziyarPanahi,unsloth,modularai,Gensyn,bartowski", True, None, current_df, progress
|
| 193 |
)
|
| 194 |
+
return current_д, load_success_flag, data_info_text, initial_status, initial_plot
|
| 195 |
|
| 196 |
def ui_generate_plot_controller(metric_choice, filter_type, tag_choice, pipeline_choice,
|
| 197 |
param_range_indices, k_orgs, skip_orgs_input, include_unknown_param_size_flag,
|
|
|
|
| 230 |
|
| 231 |
if __name__ == "__main__":
|
| 232 |
print(f"Application starting...")
|
| 233 |
+
demo.queue().launch()```
|