Duplicate from dreambooth-hackathon/leaderboard
Browse filesCo-authored-by: Lewis Tunstall <lewtun@users.noreply.huggingface.co>
- .gitattributes +34 -0
- .gitignore +160 -0
- README.md +14 -0
- app.ipynb +262 -0
- app.py +121 -0
- requirements.txt +2 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# C extensions
|
7 |
+
*.so
|
8 |
+
|
9 |
+
# Distribution / packaging
|
10 |
+
.Python
|
11 |
+
build/
|
12 |
+
develop-eggs/
|
13 |
+
dist/
|
14 |
+
downloads/
|
15 |
+
eggs/
|
16 |
+
.eggs/
|
17 |
+
lib/
|
18 |
+
lib64/
|
19 |
+
parts/
|
20 |
+
sdist/
|
21 |
+
var/
|
22 |
+
wheels/
|
23 |
+
share/python-wheels/
|
24 |
+
*.egg-info/
|
25 |
+
.installed.cfg
|
26 |
+
*.egg
|
27 |
+
MANIFEST
|
28 |
+
|
29 |
+
# PyInstaller
|
30 |
+
# Usually these files are written by a python script from a template
|
31 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
32 |
+
*.manifest
|
33 |
+
*.spec
|
34 |
+
|
35 |
+
# Installer logs
|
36 |
+
pip-log.txt
|
37 |
+
pip-delete-this-directory.txt
|
38 |
+
|
39 |
+
# Unit test / coverage reports
|
40 |
+
htmlcov/
|
41 |
+
.tox/
|
42 |
+
.nox/
|
43 |
+
.coverage
|
44 |
+
.coverage.*
|
45 |
+
.cache
|
46 |
+
nosetests.xml
|
47 |
+
coverage.xml
|
48 |
+
*.cover
|
49 |
+
*.py,cover
|
50 |
+
.hypothesis/
|
51 |
+
.pytest_cache/
|
52 |
+
cover/
|
53 |
+
|
54 |
+
# Translations
|
55 |
+
*.mo
|
56 |
+
*.pot
|
57 |
+
|
58 |
+
# Django stuff:
|
59 |
+
*.log
|
60 |
+
local_settings.py
|
61 |
+
db.sqlite3
|
62 |
+
db.sqlite3-journal
|
63 |
+
|
64 |
+
# Flask stuff:
|
65 |
+
instance/
|
66 |
+
.webassets-cache
|
67 |
+
|
68 |
+
# Scrapy stuff:
|
69 |
+
.scrapy
|
70 |
+
|
71 |
+
# Sphinx documentation
|
72 |
+
docs/_build/
|
73 |
+
|
74 |
+
# PyBuilder
|
75 |
+
.pybuilder/
|
76 |
+
target/
|
77 |
+
|
78 |
+
# Jupyter Notebook
|
79 |
+
.ipynb_checkpoints
|
80 |
+
|
81 |
+
# IPython
|
82 |
+
profile_default/
|
83 |
+
ipython_config.py
|
84 |
+
|
85 |
+
# pyenv
|
86 |
+
# For a library or package, you might want to ignore these files since the code is
|
87 |
+
# intended to run in multiple environments; otherwise, check them in:
|
88 |
+
# .python-version
|
89 |
+
|
90 |
+
# pipenv
|
91 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
92 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
93 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
94 |
+
# install all needed dependencies.
|
95 |
+
#Pipfile.lock
|
96 |
+
|
97 |
+
# poetry
|
98 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
99 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
100 |
+
# commonly ignored for libraries.
|
101 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
102 |
+
#poetry.lock
|
103 |
+
|
104 |
+
# pdm
|
105 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
106 |
+
#pdm.lock
|
107 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
108 |
+
# in version control.
|
109 |
+
# https://pdm.fming.dev/#use-with-ide
|
110 |
+
.pdm.toml
|
111 |
+
|
112 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
113 |
+
__pypackages__/
|
114 |
+
|
115 |
+
# Celery stuff
|
116 |
+
celerybeat-schedule
|
117 |
+
celerybeat.pid
|
118 |
+
|
119 |
+
# SageMath parsed files
|
120 |
+
*.sage.py
|
121 |
+
|
122 |
+
# Environments
|
123 |
+
.env
|
124 |
+
.venv
|
125 |
+
env/
|
126 |
+
venv/
|
127 |
+
ENV/
|
128 |
+
env.bak/
|
129 |
+
venv.bak/
|
130 |
+
|
131 |
+
# Spyder project settings
|
132 |
+
.spyderproject
|
133 |
+
.spyproject
|
134 |
+
|
135 |
+
# Rope project settings
|
136 |
+
.ropeproject
|
137 |
+
|
138 |
+
# mkdocs documentation
|
139 |
+
/site
|
140 |
+
|
141 |
+
# mypy
|
142 |
+
.mypy_cache/
|
143 |
+
.dmypy.json
|
144 |
+
dmypy.json
|
145 |
+
|
146 |
+
# Pyre type checker
|
147 |
+
.pyre/
|
148 |
+
|
149 |
+
# pytype static type analyzer
|
150 |
+
.pytype/
|
151 |
+
|
152 |
+
# Cython debug symbols
|
153 |
+
cython_debug/
|
154 |
+
|
155 |
+
# PyCharm
|
156 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
157 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
158 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
159 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
160 |
+
#.idea/
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Leaderboard
|
3 |
+
emoji: 😻
|
4 |
+
colorFrom: purple
|
5 |
+
colorTo: gray
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.14.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: apache-2.0
|
11 |
+
duplicated_from: dreambooth-hackathon/leaderboard
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.ipynb
ADDED
@@ -0,0 +1,262 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 14,
|
6 |
+
"id": "ae4232b9-fb9f-419a-9992-8481d1de6b61",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"# |export\n",
|
11 |
+
"import gradio as gr\n",
|
12 |
+
"import pandas as pd\n",
|
13 |
+
"from huggingface_hub import list_models"
|
14 |
+
]
|
15 |
+
},
|
16 |
+
{
|
17 |
+
"cell_type": "code",
|
18 |
+
"execution_count": 107,
|
19 |
+
"id": "51d7a652-f6d2-4cee-b787-88fc0fae0acd",
|
20 |
+
"metadata": {},
|
21 |
+
"outputs": [],
|
22 |
+
"source": [
|
23 |
+
"# |export\n",
|
24 |
+
"def make_clickable_model(model_name, link=None):\n",
|
25 |
+
" if link is None:\n",
|
26 |
+
" link = \"https://huggingface.co/\" + model_name\n",
|
27 |
+
" # Remove user from model name\n",
|
28 |
+
" return f'<a target=\"_blank\" href=\"{link}\">{model_name.split(\"/\")[-1]}</a>'\n",
|
29 |
+
"\n",
|
30 |
+
"\n",
|
31 |
+
"def make_clickable_user(user_id):\n",
|
32 |
+
" link = \"https://huggingface.co/\" + user_id\n",
|
33 |
+
" return f'<a target=\"_blank\" href=\"{link}\">{user_id}</a>'"
|
34 |
+
]
|
35 |
+
},
|
36 |
+
{
|
37 |
+
"cell_type": "code",
|
38 |
+
"execution_count": 108,
|
39 |
+
"id": "82d94a98-0e69-4400-9cb1-2e90ef6da519",
|
40 |
+
"metadata": {},
|
41 |
+
"outputs": [],
|
42 |
+
"source": [
|
43 |
+
"# |export\n",
|
44 |
+
"def get_submissions(category):\n",
|
45 |
+
" submissions = list_models(filter=[\"dreambooth-hackathon\", category], full=True)\n",
|
46 |
+
" leaderboard_models = []\n",
|
47 |
+
"\n",
|
48 |
+
" for submission in submissions:\n",
|
49 |
+
" # user, model, likes\n",
|
50 |
+
" user_id = submission.id.split(\"/\")[0]\n",
|
51 |
+
" leaderboard_models.append(\n",
|
52 |
+
" (\n",
|
53 |
+
" make_clickable_user(user_id),\n",
|
54 |
+
" make_clickable_model(submission.id),\n",
|
55 |
+
" submission.likes,\n",
|
56 |
+
" )\n",
|
57 |
+
" )\n",
|
58 |
+
"\n",
|
59 |
+
" df = pd.DataFrame(data=leaderboard_models, columns=[\"User\", \"Model\", \"Likes\"])\n",
|
60 |
+
" df.sort_values(by=[\"Likes\"], ascending=False, inplace=True)\n",
|
61 |
+
" df.insert(0, \"Rank\", list(range(1, len(df) + 1)))\n",
|
62 |
+
" return df"
|
63 |
+
]
|
64 |
+
},
|
65 |
+
{
|
66 |
+
"cell_type": "code",
|
67 |
+
"execution_count": 117,
|
68 |
+
"id": "7579bfc6-ddf6-444d-ab7e-505734d86e4d",
|
69 |
+
"metadata": {},
|
70 |
+
"outputs": [
|
71 |
+
{
|
72 |
+
"name": "stdout",
|
73 |
+
"output_type": "stream",
|
74 |
+
"text": [
|
75 |
+
"Running on local URL: http://127.0.0.1:7894\n",
|
76 |
+
"\n",
|
77 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
78 |
+
]
|
79 |
+
},
|
80 |
+
{
|
81 |
+
"data": {
|
82 |
+
"text/html": [
|
83 |
+
"<div><iframe src=\"http://127.0.0.1:7894/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
84 |
+
],
|
85 |
+
"text/plain": [
|
86 |
+
"<IPython.core.display.HTML object>"
|
87 |
+
]
|
88 |
+
},
|
89 |
+
"metadata": {},
|
90 |
+
"output_type": "display_data"
|
91 |
+
},
|
92 |
+
{
|
93 |
+
"data": {
|
94 |
+
"text/plain": []
|
95 |
+
},
|
96 |
+
"execution_count": 117,
|
97 |
+
"metadata": {},
|
98 |
+
"output_type": "execute_result"
|
99 |
+
}
|
100 |
+
],
|
101 |
+
"source": [
|
102 |
+
"# |export\n",
|
103 |
+
"block = gr.Blocks()\n",
|
104 |
+
"\n",
|
105 |
+
"with block:\n",
|
106 |
+
" gr.Markdown(\n",
|
107 |
+
" \"\"\"# The DreamBooth Hackathon Leaderboard\n",
|
108 |
+
" \n",
|
109 |
+
" 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. \n",
|
110 |
+
" \n",
|
111 |
+
" 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!\n",
|
112 |
+
" \n",
|
113 |
+
" 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).\n",
|
114 |
+
" \"\"\"\n",
|
115 |
+
" )\n",
|
116 |
+
" with gr.Tabs():\n",
|
117 |
+
" with gr.TabItem(\"Animal 🐨\"):\n",
|
118 |
+
" with gr.Row():\n",
|
119 |
+
" animal_data = gr.components.Dataframe(\n",
|
120 |
+
" type=\"pandas\", datatype=[\"number\", \"markdown\", \"markdown\", \"number\"]\n",
|
121 |
+
" )\n",
|
122 |
+
" with gr.Row():\n",
|
123 |
+
" data_run = gr.Button(\"Refresh\")\n",
|
124 |
+
" data_run.click(\n",
|
125 |
+
" get_submissions, inputs=gr.Variable(\"animal\"), outputs=animal_data\n",
|
126 |
+
" )\n",
|
127 |
+
" with gr.TabItem(\"Science 🔬\"):\n",
|
128 |
+
" with gr.Row():\n",
|
129 |
+
" science_data = gr.components.Dataframe(\n",
|
130 |
+
" type=\"pandas\", datatype=[\"number\", \"markdown\", \"markdown\", \"number\"]\n",
|
131 |
+
" )\n",
|
132 |
+
" with gr.Row():\n",
|
133 |
+
" data_run = gr.Button(\"Refresh\")\n",
|
134 |
+
" data_run.click(\n",
|
135 |
+
" get_submissions, inputs=gr.Variable(\"science\"), outputs=science_data\n",
|
136 |
+
" )\n",
|
137 |
+
" with gr.TabItem(\"Food 🍔\"):\n",
|
138 |
+
" with gr.Row():\n",
|
139 |
+
" food_data = gr.components.Dataframe(\n",
|
140 |
+
" type=\"pandas\", datatype=[\"number\", \"markdown\", \"markdown\", \"number\"]\n",
|
141 |
+
" )\n",
|
142 |
+
" with gr.Row():\n",
|
143 |
+
" data_run = gr.Button(\"Refresh\")\n",
|
144 |
+
" data_run.click(\n",
|
145 |
+
" get_submissions, inputs=gr.Variable(\"food\"), outputs=food_data\n",
|
146 |
+
" )\n",
|
147 |
+
" with gr.TabItem(\"Landscape 🏔\"):\n",
|
148 |
+
" with gr.Row():\n",
|
149 |
+
" landscape_data = gr.components.Dataframe(\n",
|
150 |
+
" type=\"pandas\", datatype=[\"number\", \"markdown\", \"markdown\", \"number\"]\n",
|
151 |
+
" )\n",
|
152 |
+
" with gr.Row():\n",
|
153 |
+
" data_run = gr.Button(\"Refresh\")\n",
|
154 |
+
" data_run.click(\n",
|
155 |
+
" get_submissions,\n",
|
156 |
+
" inputs=gr.Variable(\"landscape\"),\n",
|
157 |
+
" outputs=landscape_data,\n",
|
158 |
+
" )\n",
|
159 |
+
" with gr.TabItem(\"Wilcard 🔥\"):\n",
|
160 |
+
" with gr.Row():\n",
|
161 |
+
" wildcard_data = gr.components.Dataframe(\n",
|
162 |
+
" type=\"pandas\", datatype=[\"number\", \"markdown\", \"markdown\", \"number\"]\n",
|
163 |
+
" )\n",
|
164 |
+
" with gr.Row():\n",
|
165 |
+
" data_run = gr.Button(\"Refresh\")\n",
|
166 |
+
" data_run.click(\n",
|
167 |
+
" get_submissions,\n",
|
168 |
+
" inputs=gr.Variable(\"wildcard\"),\n",
|
169 |
+
" outputs=wildcard_data,\n",
|
170 |
+
" )\n",
|
171 |
+
"\n",
|
172 |
+
" block.load(get_submissions, inputs=gr.Variable(\"animal\"), outputs=animal_data)\n",
|
173 |
+
" block.load(get_submissions, inputs=gr.Variable(\"science\"), outputs=science_data)\n",
|
174 |
+
" block.load(get_submissions, inputs=gr.Variable(\"food\"), outputs=food_data)\n",
|
175 |
+
" block.load(get_submissions, inputs=gr.Variable(\"landscape\"), outputs=landscape_data)\n",
|
176 |
+
" block.load(get_submissions, inputs=gr.Variable(\"wildcard\"), outputs=wildcard_data)\n",
|
177 |
+
"\n",
|
178 |
+
"\n",
|
179 |
+
"block.launch()"
|
180 |
+
]
|
181 |
+
},
|
182 |
+
{
|
183 |
+
"cell_type": "code",
|
184 |
+
"execution_count": 118,
|
185 |
+
"id": "17ff7d33-0c9a-4ca0-bb7b-ba1661063035",
|
186 |
+
"metadata": {},
|
187 |
+
"outputs": [
|
188 |
+
{
|
189 |
+
"name": "stdout",
|
190 |
+
"output_type": "stream",
|
191 |
+
"text": [
|
192 |
+
"Closing server running on port: 7894\n"
|
193 |
+
]
|
194 |
+
}
|
195 |
+
],
|
196 |
+
"source": [
|
197 |
+
"block.close()"
|
198 |
+
]
|
199 |
+
},
|
200 |
+
{
|
201 |
+
"cell_type": "code",
|
202 |
+
"execution_count": 119,
|
203 |
+
"id": "339fee32-8a83-435d-b882-55b5f0994774",
|
204 |
+
"metadata": {},
|
205 |
+
"outputs": [],
|
206 |
+
"source": [
|
207 |
+
"from nbdev.export import nb_export\n",
|
208 |
+
"\n",
|
209 |
+
"nb_export(\"app.ipynb\", lib_path=\".\", name=\"app\")"
|
210 |
+
]
|
211 |
+
},
|
212 |
+
{
|
213 |
+
"cell_type": "code",
|
214 |
+
"execution_count": 77,
|
215 |
+
"id": "29f6746e-fbc3-4087-b2d8-46cd1a55e16e",
|
216 |
+
"metadata": {},
|
217 |
+
"outputs": [
|
218 |
+
{
|
219 |
+
"name": "stdout",
|
220 |
+
"output_type": "stream",
|
221 |
+
"text": [
|
222 |
+
"Writing requirements.txt\n"
|
223 |
+
]
|
224 |
+
}
|
225 |
+
],
|
226 |
+
"source": [
|
227 |
+
"%%writefile requirements.txt\n",
|
228 |
+
"pandas\n",
|
229 |
+
"huggingface_hub"
|
230 |
+
]
|
231 |
+
},
|
232 |
+
{
|
233 |
+
"cell_type": "code",
|
234 |
+
"execution_count": null,
|
235 |
+
"id": "63e8d8ea-31cc-4ddc-a08c-d9cbf02a909d",
|
236 |
+
"metadata": {},
|
237 |
+
"outputs": [],
|
238 |
+
"source": []
|
239 |
+
}
|
240 |
+
],
|
241 |
+
"metadata": {
|
242 |
+
"kernelspec": {
|
243 |
+
"display_name": "hf",
|
244 |
+
"language": "python",
|
245 |
+
"name": "hf"
|
246 |
+
},
|
247 |
+
"language_info": {
|
248 |
+
"codemirror_mode": {
|
249 |
+
"name": "ipython",
|
250 |
+
"version": 3
|
251 |
+
},
|
252 |
+
"file_extension": ".py",
|
253 |
+
"mimetype": "text/x-python",
|
254 |
+
"name": "python",
|
255 |
+
"nbconvert_exporter": "python",
|
256 |
+
"pygments_lexer": "ipython3",
|
257 |
+
"version": "3.8.13"
|
258 |
+
}
|
259 |
+
},
|
260 |
+
"nbformat": 4,
|
261 |
+
"nbformat_minor": 5
|
262 |
+
}
|
app.py
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['block', 'make_clickable_model', 'make_clickable_user', 'get_submissions']
|
5 |
+
|
6 |
+
# %% app.ipynb 0
|
7 |
+
import gradio as gr
|
8 |
+
import pandas as pd
|
9 |
+
from huggingface_hub import list_models
|
10 |
+
|
11 |
+
# %% app.ipynb 1
|
12 |
+
def make_clickable_model(model_name, link=None):
|
13 |
+
if link is None:
|
14 |
+
link = "https://huggingface.co/" + model_name
|
15 |
+
# Remove user from model name
|
16 |
+
return f'<a target="_blank" href="{link}">{model_name.split("/")[-1]}</a>'
|
17 |
+
|
18 |
+
|
19 |
+
def make_clickable_user(user_id):
|
20 |
+
link = "https://huggingface.co/" + user_id
|
21 |
+
return f'<a target="_blank" href="{link}">{user_id}</a>'
|
22 |
+
|
23 |
+
# %% app.ipynb 2
|
24 |
+
def get_submissions(category):
|
25 |
+
submissions = list_models(filter=["dreambooth-hackathon", category], full=True)
|
26 |
+
leaderboard_models = []
|
27 |
+
|
28 |
+
for submission in submissions:
|
29 |
+
# user, model, likes
|
30 |
+
user_id = submission.id.split("/")[0]
|
31 |
+
leaderboard_models.append(
|
32 |
+
(
|
33 |
+
make_clickable_user(user_id),
|
34 |
+
make_clickable_model(submission.id),
|
35 |
+
submission.likes,
|
36 |
+
)
|
37 |
+
)
|
38 |
+
|
39 |
+
df = pd.DataFrame(data=leaderboard_models, columns=["User", "Model", "Likes"])
|
40 |
+
df.sort_values(by=["Likes"], ascending=False, inplace=True)
|
41 |
+
df.insert(0, "Rank", list(range(1, len(df) + 1)))
|
42 |
+
return df
|
43 |
+
|
44 |
+
# %% app.ipynb 3
|
45 |
+
block = gr.Blocks()
|
46 |
+
|
47 |
+
with block:
|
48 |
+
gr.Markdown(
|
49 |
+
"""# The DreamBooth Hackathon Leaderboard
|
50 |
+
|
51 |
+
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.
|
52 |
+
|
53 |
+
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!
|
54 |
+
|
55 |
+
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).
|
56 |
+
"""
|
57 |
+
)
|
58 |
+
with gr.Tabs():
|
59 |
+
with gr.TabItem("Animal 🐨"):
|
60 |
+
with gr.Row():
|
61 |
+
animal_data = gr.components.Dataframe(
|
62 |
+
type="pandas", datatype=["number", "markdown", "markdown", "number"]
|
63 |
+
)
|
64 |
+
with gr.Row():
|
65 |
+
data_run = gr.Button("Refresh")
|
66 |
+
data_run.click(
|
67 |
+
get_submissions, inputs=gr.Variable("animal"), outputs=animal_data
|
68 |
+
)
|
69 |
+
with gr.TabItem("Science 🔬"):
|
70 |
+
with gr.Row():
|
71 |
+
science_data = gr.components.Dataframe(
|
72 |
+
type="pandas", datatype=["number", "markdown", "markdown", "number"]
|
73 |
+
)
|
74 |
+
with gr.Row():
|
75 |
+
data_run = gr.Button("Refresh")
|
76 |
+
data_run.click(
|
77 |
+
get_submissions, inputs=gr.Variable("science"), outputs=science_data
|
78 |
+
)
|
79 |
+
with gr.TabItem("Food 🍔"):
|
80 |
+
with gr.Row():
|
81 |
+
food_data = gr.components.Dataframe(
|
82 |
+
type="pandas", datatype=["number", "markdown", "markdown", "number"]
|
83 |
+
)
|
84 |
+
with gr.Row():
|
85 |
+
data_run = gr.Button("Refresh")
|
86 |
+
data_run.click(
|
87 |
+
get_submissions, inputs=gr.Variable("food"), outputs=food_data
|
88 |
+
)
|
89 |
+
with gr.TabItem("Landscape 🏔"):
|
90 |
+
with gr.Row():
|
91 |
+
landscape_data = gr.components.Dataframe(
|
92 |
+
type="pandas", datatype=["number", "markdown", "markdown", "number"]
|
93 |
+
)
|
94 |
+
with gr.Row():
|
95 |
+
data_run = gr.Button("Refresh")
|
96 |
+
data_run.click(
|
97 |
+
get_submissions,
|
98 |
+
inputs=gr.Variable("landscape"),
|
99 |
+
outputs=landscape_data,
|
100 |
+
)
|
101 |
+
with gr.TabItem("Wilcard 🔥"):
|
102 |
+
with gr.Row():
|
103 |
+
wildcard_data = gr.components.Dataframe(
|
104 |
+
type="pandas", datatype=["number", "markdown", "markdown", "number"]
|
105 |
+
)
|
106 |
+
with gr.Row():
|
107 |
+
data_run = gr.Button("Refresh")
|
108 |
+
data_run.click(
|
109 |
+
get_submissions,
|
110 |
+
inputs=gr.Variable("wildcard"),
|
111 |
+
outputs=wildcard_data,
|
112 |
+
)
|
113 |
+
|
114 |
+
block.load(get_submissions, inputs=gr.Variable("animal"), outputs=animal_data)
|
115 |
+
block.load(get_submissions, inputs=gr.Variable("science"), outputs=science_data)
|
116 |
+
block.load(get_submissions, inputs=gr.Variable("food"), outputs=food_data)
|
117 |
+
block.load(get_submissions, inputs=gr.Variable("landscape"), outputs=landscape_data)
|
118 |
+
block.load(get_submissions, inputs=gr.Variable("wildcard"), outputs=wildcard_data)
|
119 |
+
|
120 |
+
|
121 |
+
block.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
pandas
|
2 |
+
huggingface_hub
|