Spaces:
Sleeping
Sleeping
File size: 3,071 Bytes
080c006 250f62b 080c006 250f62b 080c006 250f62b 080c006 250f62b 080c006 250f62b 080c006 250f62b 080c006 250f62b 080c006 250f62b 080c006 250f62b 080c006 250f62b 080c006 250f62b 080c006 250f62b 080c006 250f62b 080c006 250f62b 080c006 250f62b 080c006 250f62b 080c006 |
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
__all__ = ['block', 'make_clickable_model', 'make_clickable_user', 'get_submissions']
import gradio as gr
import pandas as pd
from huggingface_hub import HfApi, repocard
def make_clickable_space(name, repo_type):
if repo_type == "spaces":
link = "https://huggingface.co/" + "spaces/" + name
elif repo_type == "models":
link = "https://huggingface.co/" + name
else:
link = "https://huggingface.co/" + "datasets/" + name
return f'<a target="_blank" href="{link}">{name.split("/")[-1]}</a>'
def get_repo_ids(repo_type):
api = HfApi()
if repo_type == "spaces":
repos = api.list_spaces(filter=["hackathon-somos-nlp-2023"])
elif repo_type == "models":
repos = api.list_models(filter=["hackathon-somos-nlp-2023"])
else:
repos = api.list_datasets(filter=["hackathon-somos-nlp-2023"])
return repos
def get_submissions(repo_type):
submissions = get_repo_ids(repo_type)
leaderboard = []
for submission in submissions:
leaderboard.append(
(
make_clickable_model(submission.id),
submission.likes,
)
)
df = pd.DataFrame(data=leaderboard, columns=[Repo", "Likes"])
df.sort_values(by=["Likes"], ascending=False, inplace=True)
df.insert(0, "Rank", list(range(1, len(df) + 1)))
return df
block = gr.Blocks()
with block:
gr.Markdown(
"""# Hackathon Somos NLP 2023 Leaderboard
"""
)
with gr.Tabs():
with gr.TabItem("Spaces (ML apps) 🐨 🌳 "):
with gr.Row():
models_data = gr.components.Dataframe(
type="pandas", datatype=["number", "markdown", "number"]
)
with gr.Row():
data_run = gr.Button("Refresh")
data_run.click(
get_submissions, inputs=gr.Variable("spaces"), outputs=nature_data
)
with gr.TabItem("Models"):
with gr.Row():
scifi_data = gr.components.Dataframe(
type="pandas", datatype=["number", "markdown", "number"]
)
with gr.Row():
data_run = gr.Button("Refresh")
data_run.click(
get_submissions, inputs=gr.Variable("models"), outputs=scifi_data
)
with gr.TabItem("Datasets"):
with gr.Row():
consentful_data = gr.components.Dataframe(
type="pandas", datatype=["number", "markdown", "number"]
)
with gr.Row():
data_run = gr.Button("Refresh")
data_run.click(
get_submissions, inputs=gr.Variable("datasets"), outputs=consentful_data
)
block.load(get_submissions, inputs=gr.Variable("spaces"), outputs=spaces_data)
block.load(get_submissions, inputs=gr.Variable("models"), outputs=models_data)
block.load(get_submissions, inputs=gr.Variable("datasets"), outputs=datasets_data)
block.launch() |