File size: 5,134 Bytes
460fdc7
 
 
7786ff5
460fdc7
 
 
 
 
f7b4006
 
7786ff5
 
 
 
 
 
 
 
 
 
 
 
f7b4006
 
 
 
 
 
7786ff5
f7b4006
 
7786ff5
 
f7b4006
 
 
 
 
 
 
 
 
7786ff5
f7b4006
 
 
7786ff5
 
 
f7d481d
 
65c5de1
f7d481d
65c5de1
7786ff5
 
f7b4006
7786ff5
f7b4006
7786ff5
 
 
f7b4006
 
 
75534b8
f7b4006
7786ff5
f7b4006
7786ff5
 
 
f7b4006
 
 
75534b8
f7b4006
7786ff5
f7b4006
7786ff5
 
 
f7b4006
 
 
75534b8
f7b4006
7786ff5
f7b4006
7786ff5
 
 
f7b4006
 
 
7786ff5
 
 
f7b4006
7786ff5
f7b4006
7786ff5
 
 
f7b4006
 
 
 
75534b8
f7b4006
 
 
 
 
 
 
 
 
 
 
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.

# %% auto 0
__all__ = ['block', 'make_clickable_model', 'make_clickable_user', 'get_submissions']

# %% app.ipynb 0
import gradio as gr
import pandas as pd
from huggingface_hub import list_models

# %% app.ipynb 1
def make_clickable_model(model_name, link=None):
    if link is None:
        link = "https://huggingface.co/" + model_name
    # Remove user from model name
    return f'<a target="_blank" href="{link}">{model_name.split("/")[-1]}</a>'


def make_clickable_user(user_id):
    link = "https://huggingface.co/" + user_id
    return f'<a  target="_blank" href="{link}">{user_id}</a>'

# %% app.ipynb 2
def get_submissions(category):
    submissions = list_models(filter=["dreambooth-hackathon", category], full=True)
    leaderboard_models = []

    for submission in submissions:
        # user, model, likes
        user_id = submission.id.split("/")[0]
        leaderboard_models.append(
            (
                make_clickable_user(user_id),
                make_clickable_model(submission.id),
                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

# %% app.ipynb 3
block = gr.Blocks()

with block:
    gr.Markdown(
        """# The DreamBooth Hackathon Leaderboard
    
    Welcome to the leaderboard for the DreamBooth Hackathon! This is a community event where particpants **personalise a Stable Diffusion model** by fine-tuning it with a powerful technique called [_DreamBooth_](https://arxiv.org/abs/2208.12242). This technique allows one to implant a subject (e.g. your pet or favourite dish) into the output domain of the model such that it can be synthesized with a _unique identifier_ in the prompt. 
    
    This competition is composed of 5 _themes_, where each theme will collect models belong to one of the categories shown in the tabs below. We'll be **giving out prizes to the top 3 most liked models per theme**, and you're encouraged to submit as many models as you want!
    
    For details on how to participate, check out the hackathon's guide [here](https://github.com/huggingface/diffusion-models-class/blob/main/hackathon/README.md).
    """
    )
    with gr.Tabs():
        with gr.TabItem("Animal 🐨"):
            with gr.Row():
                animal_data = gr.components.Dataframe(
                    type="pandas", datatype=["number", "markdown", "markdown", "number"]
                )
            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.components.Dataframe(
                    type="pandas", datatype=["number", "markdown", "markdown", "number"]
                )
            with gr.Row():
                data_run = gr.Button("Refresh")
                data_run.click(
                    get_submissions, inputs=gr.Variable("science"), outputs=science_data
                )
        with gr.TabItem("Food πŸ”"):
            with gr.Row():
                food_data = gr.components.Dataframe(
                    type="pandas", datatype=["number", "markdown", "markdown", "number"]
                )
            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.components.Dataframe(
                    type="pandas", datatype=["number", "markdown", "markdown", "number"]
                )
            with gr.Row():
                data_run = gr.Button("Refresh")
                data_run.click(
                    get_submissions,
                    inputs=gr.Variable("landscape"),
                    outputs=landscape_data,
                )
        with gr.TabItem("Wilcard πŸ”₯"):
            with gr.Row():
                wildcard_data = gr.components.Dataframe(
                    type="pandas", datatype=["number", "markdown", "markdown", "number"]
                )
            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()