OSQ-Leaderboard / app.py
SondosMB's picture
Update app.py
9eb5abe verified
import gradio as gr
import pandas as pd
from constants import INTRODUCTION_TEXT,CITATION_TEXT
# Define the formatter function
def formatter(x):
try:
return round(x, 2)
except:
return x
# Example DataFrames
jsond_data = pd.read_json('big.json')
original_df = pd.DataFrame(jsond_data)
print(original_df)
jsond_data2 = pd.read_json('small.json')
Small_original_df = pd.DataFrame(jsond_data2)
print(Small_original_df)
# Apply formatter to the entire DataFrame
original_df = original_df.applymap(formatter)
Small_original_df=Small_original_df.applymap(formatter)
# Correct data types for Gradio DataFrame component
TYPES = ['str', 'number', 'number', 'number']
LAST_UPDATED = "June 9th 2024"
# CSS for styling
css = """
.markdown-text{font-size: 200pt}
.markdown-text-small{font-size: 13pt}
th {
text-align: center;
}
td {
font-size: 15px; /* Adjust the font size as needed */
text-align: center;
}
#od-benchmark-tab-table-button{
font-size: 15pt;
font-weight: bold;
}
#Intro{
font-size: 100pt;
}
"""
def build_demo(original_df,Small_original_df, TYPES):
with gr.Blocks(css=css) as demo:
gr.Markdown(INTRODUCTION_TEXT, elem_id="Intro")
with gr.Tabs():
with gr.TabItem("🏅Large-Scale LLMs leaderboard",elem_id="od-benchmark-tab-table", id=0):
leaderboard_table = gr.components.Dataframe(
value=original_df,
datatype=TYPES,
label="Leaderboard_Large",
height=1000,
wrap=False,
interactive=False,
visible=True,
min_width=60,
)
with gr.TabItem("🏅Small-Scale LLMS leaderboard",elem_id="od-benchmark-tab-table", id=1):
leaderboard_table = gr.components.Dataframe(
value=Small_original_df,
datatype=TYPES,
label="Leaderboard_Small",
height=1000,
wrap=False,
interactive=False,
visible=True,
min_width=60,
)
gr.Markdown(f"Last updated on **{LAST_UPDATED}**", elem_classes="markdown-text-small")
with gr.Row():
with gr.Accordion("📙 Citation", open=False):
gr.Textbox(
value=CITATION_TEXT, lines=18,
label="",
elem_id="citation-button",
show_copy_button=True)
return demo
demo = build_demo(original_df,Small_original_df, TYPES)
demo.launch(share='True')