MMEB / app.py
wenhu's picture
Update app.py
0d3eb4f verified
from utils import *
global data_component
def update_table(query, min_size, max_size, selected_tasks=None):
df = get_df()
filtered_df = search_and_filter_models(df, query, min_size, max_size)
if selected_tasks and len(selected_tasks) > 0:
selected_columns = BASE_COLS + selected_tasks
filtered_df = filtered_df[selected_columns]
return filtered_df
with gr.Blocks() as block:
gr.Markdown(LEADERBOARD_INTRODUCTION)
with gr.Tabs(elem_classes="tab-buttons") as tabs:
# Table 1
with gr.TabItem("πŸ“Š MMEB", elem_id="qa-tab-table1", id=1):
with gr.Row():
with gr.Accordion("Citation", open=False):
citation_button = gr.Textbox(
value=CITATION_BUTTON_TEXT,
label=CITATION_BUTTON_LABEL,
elem_id="citation-button",
lines=10,
)
gr.Markdown(TABLE_INTRODUCTION)
with gr.Row():
search_bar = gr.Textbox(
placeholder="Search models...",
show_label=False,
elem_id="search-bar"
)
df = get_df()
min_size, max_size = get_size_range(df)
with gr.Row():
min_size_slider = gr.Slider(
minimum=min_size,
maximum=max_size,
value=min_size,
step=0.1,
label="Minimum number of parameters (B)",
)
max_size_slider = gr.Slider(
minimum=min_size,
maximum=max_size,
value=max_size,
step=0.1,
label="Maximum number of parameters (B)",
)
task_choices = [col for col in COLUMN_NAMES if col not in BASE_COLS]
with gr.Row():
tasks_select = gr.CheckboxGroup(
choices=task_choices,
value=task_choices,
label="Select tasks to Display",
elem_id="tasks-select"
)
data_component = gr.components.Dataframe(
value=df[COLUMN_NAMES],
headers=COLUMN_NAMES,
type="pandas",
datatype=DATA_TITLE_TYPE,
interactive=False,
visible=True,
)
refresh_button = gr.Button("Refresh")
def update_with_tasks(*args):
return update_table(*args)
search_bar.change(
fn=update_with_tasks,
inputs=[search_bar, min_size_slider, max_size_slider, tasks_select],
outputs=data_component
)
min_size_slider.change(
fn=update_with_tasks,
inputs=[search_bar, min_size_slider, max_size_slider, tasks_select],
outputs=data_component
)
max_size_slider.change(
fn=update_with_tasks,
inputs=[search_bar, min_size_slider, max_size_slider, tasks_select],
outputs=data_component
)
tasks_select.change(
fn=update_with_tasks,
inputs=[search_bar, min_size_slider, max_size_slider, tasks_select],
outputs=data_component
)
refresh_button.click(fn=refresh_data, outputs=data_component)
# table 2
with gr.TabItem("πŸ“ About", elem_id="qa-tab-table2", id=2):
gr.Markdown(LEADERBOARD_INFO, elem_classes="markdown-text")
# table 3
with gr.TabItem("πŸš€ Submit here! ", elem_id="submit-tab", id=3):
with gr.Row():
gr.Markdown(SUBMIT_INTRODUCTION, elem_classes="markdown-text")
block.launch(share=True)