lewtun HF staff commited on
Commit
460fdc7
β€’
1 Parent(s): da611bb
Files changed (4) hide show
  1. .gitignore +160 -0
  2. app.ipynb +228 -0
  3. app.py +9 -0
  4. requirements.txt +2 -0
.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/
app.ipynb ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": 71,
19
+ "id": "82d94a98-0e69-4400-9cb1-2e90ef6da519",
20
+ "metadata": {},
21
+ "outputs": [],
22
+ "source": [
23
+ "# |export\n",
24
+ "def get_submissions(category):\n",
25
+ " submissions = list_models(filter=[\"dreambooth-hackathon\", category], full=True)\n",
26
+ " leaderboard_models = []\n",
27
+ "\n",
28
+ " for submission in submissions:\n",
29
+ " # user, model, likes\n",
30
+ " leaderboard_models.append(\n",
31
+ " (\n",
32
+ " submission.id.split(\"/\")[0],\n",
33
+ " submission.id.split(\"/\")[-1],\n",
34
+ " submission.likes,\n",
35
+ " )\n",
36
+ " )\n",
37
+ "\n",
38
+ " df = pd.DataFrame(data=leaderboard_models, columns=[\"User\", \"Model\", \"Likes\"])\n",
39
+ " df.sort_values(by=[\"Likes\"], ascending=False, inplace=True)\n",
40
+ " df.insert(0, \"Rank\", list(range(1, len(df) + 1)))\n",
41
+ " return df"
42
+ ]
43
+ },
44
+ {
45
+ "cell_type": "code",
46
+ "execution_count": 74,
47
+ "id": "7579bfc6-ddf6-444d-ab7e-505734d86e4d",
48
+ "metadata": {},
49
+ "outputs": [
50
+ {
51
+ "name": "stderr",
52
+ "output_type": "stream",
53
+ "text": [
54
+ "/Users/lewtun/miniconda3/envs/hf/lib/python3.8/site-packages/gradio/outputs.py:127: UserWarning: Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components\n",
55
+ " warnings.warn(\n"
56
+ ]
57
+ },
58
+ {
59
+ "name": "stdout",
60
+ "output_type": "stream",
61
+ "text": [
62
+ "Running on local URL: http://127.0.0.1:7876\n",
63
+ "\n",
64
+ "To create a public link, set `share=True` in `launch()`.\n"
65
+ ]
66
+ },
67
+ {
68
+ "data": {
69
+ "text/html": [
70
+ "<div><iframe src=\"http://127.0.0.1:7876/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
71
+ ],
72
+ "text/plain": [
73
+ "<IPython.core.display.HTML object>"
74
+ ]
75
+ },
76
+ "metadata": {},
77
+ "output_type": "display_data"
78
+ },
79
+ {
80
+ "data": {
81
+ "text/plain": []
82
+ },
83
+ "execution_count": 74,
84
+ "metadata": {},
85
+ "output_type": "execute_result"
86
+ }
87
+ ],
88
+ "source": [
89
+ "# |export\n",
90
+ "block = gr.Blocks()\n",
91
+ "\n",
92
+ "with block:\n",
93
+ " gr.Markdown(\"hi\")\n",
94
+ " with gr.Tabs():\n",
95
+ " with gr.TabItem(\"Animal\"):\n",
96
+ " with gr.Row():\n",
97
+ " animal_data = gr.outputs.Dataframe(type=\"pandas\")\n",
98
+ " with gr.Row():\n",
99
+ " data_run = gr.Button(\"Refresh\")\n",
100
+ " data_run.click(\n",
101
+ " get_submissions, inputs=gr.Variable(\"Animal\"), outputs=animal_data\n",
102
+ " )\n",
103
+ " with gr.TabItem(\"Science\"):\n",
104
+ " with gr.Row():\n",
105
+ " science_data = gr.outputs.Dataframe(type=\"pandas\")\n",
106
+ " with gr.Row():\n",
107
+ " data_run = gr.Button(\"Refresh\")\n",
108
+ " data_run.click(\n",
109
+ " get_submissions, inputs=gr.Variable(\"Animal\"), outputs=science_data\n",
110
+ " )\n",
111
+ " with gr.TabItem(\"Food\"):\n",
112
+ " with gr.Row():\n",
113
+ " food_data = gr.outputs.Dataframe(type=\"pandas\")\n",
114
+ " with gr.Row():\n",
115
+ " data_run = gr.Button(\"Refresh\")\n",
116
+ " data_run.click(\n",
117
+ " get_submissions, inputs=gr.Variable(\"Food\"), outputs=food_data\n",
118
+ " )\n",
119
+ " with gr.TabItem(\"Landscape\"):\n",
120
+ " with gr.Row():\n",
121
+ " landscape_data = gr.outputs.Dataframe(type=\"pandas\")\n",
122
+ " with gr.Row():\n",
123
+ " data_run = gr.Button(\"Refresh\")\n",
124
+ " data_run.click(\n",
125
+ " get_submissions, inputs=gr.Variable(\"Landscape\"), outputs=data\n",
126
+ " )\n",
127
+ " with gr.TabItem(\"Wilcard\"):\n",
128
+ " with gr.Row():\n",
129
+ " wildcard_data = gr.outputs.Dataframe(type=\"pandas\")\n",
130
+ " with gr.Row():\n",
131
+ " data_run = gr.Button(\"Refresh\")\n",
132
+ " data_run.click(\n",
133
+ " get_submissions,\n",
134
+ " inputs=gr.Variable(\"Wildcard\"),\n",
135
+ " outputs=wildcard_data,\n",
136
+ " )\n",
137
+ "\n",
138
+ " block.load(get_submissions, inputs=gr.Variable(\"animal\"), outputs=animal_data)\n",
139
+ " block.load(get_submissions, inputs=gr.Variable(\"science\"), outputs=science_data)\n",
140
+ " block.load(get_submissions, inputs=gr.Variable(\"food\"), outputs=food_data)\n",
141
+ " block.load(get_submissions, inputs=gr.Variable(\"landscape\"), outputs=landscape_data)\n",
142
+ " block.load(get_submissions, inputs=gr.Variable(\"wildcard\"), outputs=wildcard_data)\n",
143
+ "\n",
144
+ "\n",
145
+ "block.launch()"
146
+ ]
147
+ },
148
+ {
149
+ "cell_type": "code",
150
+ "execution_count": 75,
151
+ "id": "17ff7d33-0c9a-4ca0-bb7b-ba1661063035",
152
+ "metadata": {},
153
+ "outputs": [
154
+ {
155
+ "name": "stdout",
156
+ "output_type": "stream",
157
+ "text": [
158
+ "Closing server running on port: 7876\n"
159
+ ]
160
+ }
161
+ ],
162
+ "source": [
163
+ "block.close()"
164
+ ]
165
+ },
166
+ {
167
+ "cell_type": "code",
168
+ "execution_count": 76,
169
+ "id": "339fee32-8a83-435d-b882-55b5f0994774",
170
+ "metadata": {},
171
+ "outputs": [],
172
+ "source": [
173
+ "from nbdev.export import nb_export\n",
174
+ "\n",
175
+ "nb_export(\"app.ipynb\", lib_path=\".\", name=\"app\")"
176
+ ]
177
+ },
178
+ {
179
+ "cell_type": "code",
180
+ "execution_count": 77,
181
+ "id": "29f6746e-fbc3-4087-b2d8-46cd1a55e16e",
182
+ "metadata": {},
183
+ "outputs": [
184
+ {
185
+ "name": "stdout",
186
+ "output_type": "stream",
187
+ "text": [
188
+ "Writing requirements.txt\n"
189
+ ]
190
+ }
191
+ ],
192
+ "source": [
193
+ "%%writefile requirements.txt\n",
194
+ "pandas\n",
195
+ "huggingface_hub"
196
+ ]
197
+ },
198
+ {
199
+ "cell_type": "code",
200
+ "execution_count": null,
201
+ "id": "63e8d8ea-31cc-4ddc-a08c-d9cbf02a909d",
202
+ "metadata": {},
203
+ "outputs": [],
204
+ "source": []
205
+ }
206
+ ],
207
+ "metadata": {
208
+ "kernelspec": {
209
+ "display_name": "hf",
210
+ "language": "python",
211
+ "name": "hf"
212
+ },
213
+ "language_info": {
214
+ "codemirror_mode": {
215
+ "name": "ipython",
216
+ "version": 3
217
+ },
218
+ "file_extension": ".py",
219
+ "mimetype": "text/x-python",
220
+ "name": "python",
221
+ "nbconvert_exporter": "python",
222
+ "pygments_lexer": "ipython3",
223
+ "version": "3.8.13"
224
+ }
225
+ },
226
+ "nbformat": 4,
227
+ "nbformat_minor": 5
228
+ }
app.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = []
5
+
6
+ # %% app.ipynb 0
7
+ import gradio as gr
8
+ import pandas as pd
9
+ from huggingface_hub import list_models
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ pandas
2
+ huggingface_hub