|
|
|
|
|
|
|
__all__ = ['block', 'get_submissions'] |
|
|
|
|
|
import gradio as gr |
|
import pandas as pd |
|
from huggingface_hub import list_models |
|
|
|
|
|
def get_submissions(category): |
|
submissions = list_models(filter=["dreambooth-hackathon", category], full=True) |
|
leaderboard_models = [] |
|
|
|
for submission in submissions: |
|
|
|
leaderboard_models.append( |
|
( |
|
submission.id.split("/")[0], |
|
submission.id.split("/")[-1], |
|
submission.likes, |
|
) |
|
) |
|
|
|
df = pd.DataFrame(data=leaderboard_models, columns=["User", "Model", "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("hi") |
|
with gr.Tabs(): |
|
with gr.TabItem("Animal"): |
|
with gr.Row(): |
|
animal_data = gr.outputs.Dataframe(type="pandas") |
|
with gr.Row(): |
|
data_run = gr.Button("Refresh") |
|
data_run.click( |
|
get_submissions, inputs=gr.Variable("Animal"), outputs=animal_data |
|
) |
|
with gr.TabItem("Science"): |
|
with gr.Row(): |
|
science_data = gr.outputs.Dataframe(type="pandas") |
|
with gr.Row(): |
|
data_run = gr.Button("Refresh") |
|
data_run.click( |
|
get_submissions, inputs=gr.Variable("Animal"), outputs=science_data |
|
) |
|
with gr.TabItem("Food"): |
|
with gr.Row(): |
|
food_data = gr.outputs.Dataframe(type="pandas") |
|
with gr.Row(): |
|
data_run = gr.Button("Refresh") |
|
data_run.click( |
|
get_submissions, inputs=gr.Variable("Food"), outputs=food_data |
|
) |
|
with gr.TabItem("Landscape"): |
|
with gr.Row(): |
|
landscape_data = gr.outputs.Dataframe(type="pandas") |
|
with gr.Row(): |
|
data_run = gr.Button("Refresh") |
|
data_run.click( |
|
get_submissions, inputs=gr.Variable("Landscape"), outputs=data |
|
) |
|
with gr.TabItem("Wilcard"): |
|
with gr.Row(): |
|
wildcard_data = gr.outputs.Dataframe(type="pandas") |
|
with gr.Row(): |
|
data_run = gr.Button("Refresh") |
|
data_run.click( |
|
get_submissions, |
|
inputs=gr.Variable("Wildcard"), |
|
outputs=wildcard_data, |
|
) |
|
|
|
block.load(get_submissions, inputs=gr.Variable("animal"), outputs=animal_data) |
|
block.load(get_submissions, inputs=gr.Variable("science"), outputs=science_data) |
|
block.load(get_submissions, inputs=gr.Variable("food"), outputs=food_data) |
|
block.load(get_submissions, inputs=gr.Variable("landscape"), outputs=landscape_data) |
|
block.load(get_submissions, inputs=gr.Variable("wildcard"), outputs=wildcard_data) |
|
|
|
|
|
block.launch() |
|
|