Spaces:
Running
Running
File size: 1,375 Bytes
0f89c55 733bd44 0f89c55 733bd44 0f89c55 733bd44 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# gradio display leaderboard
import pandas as pd
import numpy as np
import matplotlib
# matplotlib.use('macosx')
import gradio as gr
import matplotlib.pyplot as plt
import plotly.graph_objects as go
from apscheduler.schedulers.background import BackgroundScheduler
from texts import INTRODUCTION_TEXT, TITLE
df_lang = {
'en': pd.DataFrame({
'name': ['GPT-3', 'T5', 'BERT', 'RoBERTa', 'XLNet'],
'score': [0.75, 0.72, 0.68, 0.65, 0.62],
'rank': [1, 2, 3, 4, 5]
}),
'zh': pd.DataFrame({
'name': ['GPT-3', 'T5', 'BERT', 'RoBERTa', 'XLNet'],
'score': [0.75, 0.72, 0.68, 0.65, 0.62],
'rank': [1, 2, 3, 4, 5]
}),
}
def create_lang_leader_board(df):
headers = df.columns
types = ["str"] + ["number"] * (len(headers) - 1)
return gr.components.Dataframe(
value=df.values.tolist(),
headers=[col_name for col_name in headers],
datatype=types,
# max_rows=10,
)
def launch_gradio():
demo = gr.Blocks()
with demo:
gr.HTML(TITLE)
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
for key, df in df_lang.items():
with gr.Tab(key):
create_lang_leader_board(df)
demo.launch()
scheduler = BackgroundScheduler()
scheduler.add_job(launch_gradio, 'interval', hours=1)
scheduler.start()
launch_gradio() |