Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -2,9 +2,13 @@ from utils import *
|
|
2 |
|
3 |
global data_component
|
4 |
|
5 |
-
def update_table(query, min_size, max_size):
|
6 |
df = get_df()
|
7 |
filtered_df = search_and_filter_models(df, query, min_size, max_size)
|
|
|
|
|
|
|
|
|
8 |
return filtered_df
|
9 |
|
10 |
with gr.Blocks() as block:
|
@@ -49,6 +53,16 @@ with gr.Blocks() as block:
|
|
49 |
label="Maximum number of parameters (B)",
|
50 |
)
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
data_component = gr.components.Dataframe(
|
53 |
value=df[COLUMN_NAMES],
|
54 |
headers=COLUMN_NAMES,
|
@@ -60,9 +74,31 @@ with gr.Blocks() as block:
|
|
60 |
)
|
61 |
|
62 |
refresh_button = gr.Button("Refresh")
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
refresh_button.click(fn=refresh_data, outputs=data_component)
|
67 |
|
68 |
# table 2
|
|
|
2 |
|
3 |
global data_component
|
4 |
|
5 |
+
def update_table(query, min_size, max_size, selected_subjects=None):
|
6 |
df = get_df()
|
7 |
filtered_df = search_and_filter_models(df, query, min_size, max_size)
|
8 |
+
if selected_subjects and len(selected_subjects) > 0:
|
9 |
+
base_columns = ['Models', 'Model Size(B)', 'Data Source', 'Overall']
|
10 |
+
selected_columns = base_columns + selected_subjects
|
11 |
+
filtered_df = filtered_df[selected_columns]
|
12 |
return filtered_df
|
13 |
|
14 |
with gr.Blocks() as block:
|
|
|
53 |
label="Maximum number of parameters (B)",
|
54 |
)
|
55 |
|
56 |
+
# 添加学科选择器
|
57 |
+
subject_choices = [col for col in COLUMN_NAMES if col not in ['Models', 'Model Size(B)', 'Data Source', 'Overall']]
|
58 |
+
with gr.Row():
|
59 |
+
subjects_select = gr.CheckboxGroup(
|
60 |
+
choices=subject_choices,
|
61 |
+
value=subject_choices, # 默认全选
|
62 |
+
label="Select Subjects to Display",
|
63 |
+
elem_id="subjects-select"
|
64 |
+
)
|
65 |
+
|
66 |
data_component = gr.components.Dataframe(
|
67 |
value=df[COLUMN_NAMES],
|
68 |
headers=COLUMN_NAMES,
|
|
|
74 |
)
|
75 |
|
76 |
refresh_button = gr.Button("Refresh")
|
77 |
+
|
78 |
+
# 更新事件处理
|
79 |
+
def update_with_subjects(*args):
|
80 |
+
return update_table(*args)
|
81 |
+
|
82 |
+
search_bar.change(
|
83 |
+
fn=update_with_subjects,
|
84 |
+
inputs=[search_bar, min_size_slider, max_size_slider, subjects_select],
|
85 |
+
outputs=data_component
|
86 |
+
)
|
87 |
+
min_size_slider.change(
|
88 |
+
fn=update_with_subjects,
|
89 |
+
inputs=[search_bar, min_size_slider, max_size_slider, subjects_select],
|
90 |
+
outputs=data_component
|
91 |
+
)
|
92 |
+
max_size_slider.change(
|
93 |
+
fn=update_with_subjects,
|
94 |
+
inputs=[search_bar, min_size_slider, max_size_slider, subjects_select],
|
95 |
+
outputs=data_component
|
96 |
+
)
|
97 |
+
subjects_select.change(
|
98 |
+
fn=update_with_subjects,
|
99 |
+
inputs=[search_bar, min_size_slider, max_size_slider, subjects_select],
|
100 |
+
outputs=data_component
|
101 |
+
)
|
102 |
refresh_button.click(fn=refresh_data, outputs=data_component)
|
103 |
|
104 |
# table 2
|