sasha HF staff commited on
Commit
68d4e1e
·
verified ·
1 Parent(s): 6271469

Delete app.ipynb

Browse files
Files changed (1) hide show
  1. app.ipynb +0 -262
app.ipynb DELETED
@@ -1,262 +0,0 @@
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
- }