Spaces:
Running
Running
import gradio as gr | |
from utils import get_leaderboard_data, SUPER_GROUPS, MODEL_GROUPS | |
import os | |
from constants import * | |
# Get the directory of the current script | |
current_dir = os.path.dirname(os.path.abspath(__file__)) | |
# Construct the path to the CSS file | |
css_file = os.path.join(current_dir, "static", "css", "style.css") | |
# Read the CSS file | |
with open(css_file, "r") as f: | |
css = f.read() | |
def update_leaderboard(selected_super_group, selected_model_group): | |
headers, data = get_leaderboard_data(selected_super_group, selected_model_group) | |
return gr.Dataframe( | |
value=data, | |
headers=headers, | |
datatype=["str"] + ["number"] * (len(headers) - 1), | |
) | |
with gr.Blocks(css=css) as block: | |
gr.Markdown( | |
LEADERBOARD_INTRODUCTION | |
) | |
with gr.Tabs(elem_classes="tab-buttons") as tabs: | |
with gr.TabItem("π MEGA-Bench", 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(): | |
super_group_selector = gr.Radio( | |
choices=list(SUPER_GROUPS.keys()), | |
label="Select a dimension to display breakdown results", | |
value=list(SUPER_GROUPS.keys())[0] | |
) | |
model_group_selector = gr.Radio( | |
choices=list(MODEL_GROUPS.keys()), | |
label="Select a model group", | |
value="All" | |
) | |
initial_headers, initial_data = get_leaderboard_data(list(SUPER_GROUPS.keys())[0], "All") | |
data_component = gr.Dataframe( | |
value=initial_data, | |
headers=initial_headers, | |
datatype=["str"] + ["number"] * (len(initial_headers) - 1), | |
interactive=False, | |
elem_classes="custom-dataframe", | |
) | |
refresh_button = gr.Button("Refresh") | |
refresh_button.click(fn=update_leaderboard, inputs=[super_group_selector, model_group_selector], outputs=[data_component]) | |
super_group_selector.change(fn=update_leaderboard, inputs=[super_group_selector, model_group_selector], outputs=[data_component]) | |
model_group_selector.change(fn=update_leaderboard, inputs=[super_group_selector, model_group_selector], outputs=[data_component]) | |
with gr.TabItem("π Data Information", elem_id="qa-tab-table2", id=2): | |
gr.Markdown(DATA_INFO, elem_classes="markdown-text") | |
with gr.TabItem("π Submit here! ", elem_id="submit-tab", id=3): | |
with gr.Row(): | |
gr.Markdown(SUBMIT_INTRODUCTION, elem_classes="markdown-text") | |
if __name__ == "__main__": | |
block.launch(share=True) | |
#block.launch(server_name="127.0.0.1", server_port=7860) | |