michal
Upload
64a7fed
raw
history blame
6.67 kB
import gradio as gr
from gradio_leaderboard import Leaderboard
from pathlib import Path
import pandas as pd
from src.styles import custom_css
from src.structures.leaderboard_structure import (LB_LLMZSZL,
ORDER_LIST,
DATA_TYPES,
COLUMN_HEADERS,
filter_data,
filter_columns,
)
from src.structures.gim import GIM_SCORES
from src.structures.zaw import ZAW_SCORES
from src.structures.mat import MAT_SCORES
from src.structures.osm import OSM_SCORES
global data_component
from src.abouts import *
polygon_svg = """
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
x="0px" y="0px" viewBox="0 0 200 100" width="200px" height="100px" style="enable-background:new 0 0 200 100;"
xml:space="preserve">
<style type="text/css">
.st0{fill:#E52713;}
.st1{fill:#FFFFFF;}
</style>
<g>
<polygon class="st0" points="147.4,97.1 147.4,107.5 137,107.5 137,103.1 126.1,103.1 126.1,104.7 121.3,104.7 121.3,103.1
110.8,103.1 110.8,107.5 100.4,107.5 100.4,97.1 110.8,97.1 110.8,101.5 121.3,101.5 121.3,99.9 126.1,99.9 126.1,101.5 137,101.5
137,97.1"></polygon>
<polygon class="st0" points="168.3,74.9 168.3,85.3 157.8,85.3 157.8,80.9 137,80.9 137,85.3 126.6,85.3 126.6,80.9 108.7,80.9
108.7,89.2 90.4,89.2 90.4,80.9 69.6,80.9 69.6,82.5 64.8,82.5 64.8,80.9 48,80.9 48,85.3 37.5,85.3 37.5,74.9 48,74.9 48,79.3
64.8,79.3 64.8,77.7 69.6,77.7 69.6,79.3 90.4,79.3 90.4,70.9 108.7,70.9 108.7,79.3 126.6,79.3 126.6,74.9 137,74.9 137,79.3
157.8,79.3 157.8,74.9"></polygon>
<polygon class="st0" points="174.7,51.7 174.7,62.1 164.3,62.1 164.3,57.7 150.3,57.7 150.3,59.3 145.4,59.3 145.4,57.7
130.6,57.7 130.6,64.6 115.2,64.6 115.2,57.7 102,57.7 102,59.3 97.2,59.3 97.2,57.7 84.5,57.7 84.5,68.4 61.4,68.4 61.4,57.7
51.2,57.7 51.2,62.1 40.8,62.1 40.8,57.7 30.7,57.7 30.7,62.1 20.3,62.1 20.3,51.7 30.7,51.7 30.7,56.1 40.8,56.1 40.8,51.7
51.2,51.7 51.2,56.1 61.4,56.1 61.4,45.3 84.5,45.3 84.5,56.1 97.2,56.1 97.2,54.5 102,54.5 102,56.1 115.2,56.1 115.2,49.2
130.6,49.2 130.6,56.1 145.4,56.1 145.4,54.5 150.3,54.5 150.3,56.1 164.3,56.1 164.3,51.7"></polygon>
<polygon class="st0" points="155.5,32.2 155.5,42.6 145.1,42.6 145.1,38.2 125.7,38.2 125.7,39.8 120.9,39.8 120.9,38.2 98.7,38.2
98.7,42.6 88.3,42.6 88.3,38.2 53.2,38.2 53.2,42.6 42.8,42.6 42.8,32.2 53.2,32.2 53.2,36.6 88.3,36.6 88.3,32.2 98.7,32.2
98.7,36.6 120.9,36.6 120.9,35 125.7,35 125.7,36.6 145.1,36.6 145.1,32.2"></polygon>
<polygon class="st0" points="125.6,16.2 125.6,26.6 115.2,26.6 115.2,22.2 102.5,22.2 102.5,23.9 97.7,23.9 97.7,22.2 85.1,22.2
85.1,26.6 74.7,26.6 74.7,16.2 85.1,16.2 85.1,20.6 97.7,20.6 97.7,19 102.5,19 102.5,20.6 115.2,20.6 115.2,16.2"></polygon>
<rect x="128" y="116.8" class="st0" width="10.4" height="10.4"></rect>
</g>
</svg>
"""
main = gr.Blocks(css=custom_css)
with main:
gr.HTML(polygon_svg)
with gr.Row():
with gr.Column():
# image = gr.Image("src/images/logo.png",
# show_download_button=False,
# show_share_button=False,
# show_fullscreen_button=False,
# container=False)
gr.HTML(polygon_svg)
with gr.Column():
gr.HTML(HEADER_TITLE)
with gr.Tabs(elem_classes="tab-buttons") as tabs:
with gr.Tab("πŸ… LLMZSZL"):
gr.Markdown("""## Overall scores""")
# Checkbox to toggle column visibility
columns_selector = gr.CheckboxGroup(
choices=ORDER_LIST,
label="Select columns to display",
value=ORDER_LIST,
)
# Dataframe component to display the leaderboard data
data_component = gr.components.Dataframe(
value=LB_LLMZSZL,
headers=COLUMN_HEADERS,
type="pandas",
datatype=DATA_TYPES,
interactive=False,
visible=True,
column_widths=[400, 200, 100, 120, 100]
)
# def update_data(selected_columns, selected_languages):
# return update_dataframe(selected_columns, selected_languages)
def update_dataframe(selected_columns):
return filter_columns(selected_columns)
columns_selector.change(update_dataframe, inputs=columns_selector, outputs=data_component)
# language_selector.change(update_data, inputs=[columns_selector, language_selector], outputs=data_component)
with gr.Tab("πŸ“ Middle School exam"):
gr.Markdown(GIM_DESC)
data_component = gr.components.Dataframe(
value=GIM_SCORES,
type="pandas",
interactive=False,
visible=True,
datatype=["markdown"]+["number"]*18,
column_widths=[400] + [80] * 18
)
with gr.Tab("πŸ“ 8-grade exam"):
gr.Markdown(OSM_DESC)
data_component = gr.components.Dataframe(
value=OSM_SCORES,
type="pandas",
interactive=False,
visible=True,
datatype=["markdown"]+["number"]*5,
column_widths=[400] + [80] * 5
)
with gr.Tab("πŸ“ High School exam"):
gr.Markdown(MAT_DESC)
data_component = gr.components.Dataframe(
value=MAT_SCORES,
type="pandas",
interactive=False,
visible=True,
datatype=["markdown"]+["number"]*22,
column_widths=[400] + [80] * 22
)
with gr.Tab("πŸ“ Professional exam"):
gr.Markdown(ZAW_DESC)
data_component = gr.components.Dataframe(
value=ZAW_SCORES,
type="pandas",
interactive=False,
visible=True,
datatype=["markdown"]+["number"]*12,
column_widths=[400] + [80] * 12
)
with gr.Tab("πŸ“ About"):
gr.Markdown(ABOUT)
with gr.Column():
with gr.Accordion("πŸ“™ Citation", open=False):
citation_button = gr.Textbox(
value="TEST",
label="TEST_LABEL",
lines=20,
elem_id="citation-button",
show_copy_button=True,
)
if __name__ == "__main__":
main.launch()