lewtun HF staff commited on
Commit
7786ff5
β€’
1 Parent(s): 75534b8
Files changed (2) hide show
  1. app.ipynb +63 -33
  2. app.py +46 -16
app.ipynb CHANGED
@@ -7,7 +7,7 @@
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"
@@ -15,22 +15,43 @@
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",
@@ -43,23 +64,15 @@
43
  },
44
  {
45
  "cell_type": "code",
46
- "execution_count": 82,
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:7878\n",
63
  "\n",
64
  "To create a public link, set `share=True` in `launch()`.\n"
65
  ]
@@ -67,7 +80,7 @@
67
  {
68
  "data": {
69
  "text/html": [
70
- "<div><iframe src=\"http://127.0.0.1:7878/\" 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>"
@@ -80,53 +93,70 @@
80
  "data": {
81
  "text/plain": []
82
  },
83
- "execution_count": 82,
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(\"science\"), 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=landscape_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",
@@ -147,7 +177,7 @@
147
  },
148
  {
149
  "cell_type": "code",
150
- "execution_count": 83,
151
  "id": "17ff7d33-0c9a-4ca0-bb7b-ba1661063035",
152
  "metadata": {},
153
  "outputs": [
@@ -155,7 +185,7 @@
155
  "name": "stdout",
156
  "output_type": "stream",
157
  "text": [
158
- "Closing server running on port: 7878\n"
159
  ]
160
  }
161
  ],
@@ -165,7 +195,7 @@
165
  },
166
  {
167
  "cell_type": "code",
168
- "execution_count": 79,
169
  "id": "339fee32-8a83-435d-b882-55b5f0994774",
170
  "metadata": {},
171
  "outputs": [],
 
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"
 
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",
 
64
  },
65
  {
66
  "cell_type": "code",
67
+ "execution_count": 109,
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:7889\n",
76
  "\n",
77
  "To create a public link, set `share=True` in `launch()`.\n"
78
  ]
 
80
  {
81
  "data": {
82
  "text/html": [
83
+ "<div><iframe src=\"http://127.0.0.1:7889/\" 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>"
 
93
  "data": {
94
  "text/plain": []
95
  },
96
+ "execution_count": 109,
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! \n",
110
+ " \"\"\"\n",
111
+ " )\n",
112
  " with gr.Tabs():\n",
113
+ " with gr.TabItem(\"Animal 🐨\"):\n",
114
  " with gr.Row():\n",
115
+ " animal_data = gr.components.Dataframe(\n",
116
+ " type=\"pandas\", datatype=[\"number\", \"markdown\", \"markdown\", \"number\"]\n",
117
+ " )\n",
118
  " with gr.Row():\n",
119
  " data_run = gr.Button(\"Refresh\")\n",
120
  " data_run.click(\n",
121
  " get_submissions, inputs=gr.Variable(\"animal\"), outputs=animal_data\n",
122
  " )\n",
123
+ " with gr.TabItem(\"Science πŸ”¬\"):\n",
124
  " with gr.Row():\n",
125
+ " science_data = gr.components.Dataframe(\n",
126
+ " type=\"pandas\", datatype=[\"number\", \"markdown\", \"markdown\", \"number\"]\n",
127
+ " )\n",
128
  " with gr.Row():\n",
129
  " data_run = gr.Button(\"Refresh\")\n",
130
  " data_run.click(\n",
131
  " get_submissions, inputs=gr.Variable(\"science\"), outputs=science_data\n",
132
  " )\n",
133
+ " with gr.TabItem(\"Food πŸ”\"):\n",
134
  " with gr.Row():\n",
135
+ " food_data = gr.components.Dataframe(\n",
136
+ " type=\"pandas\", datatype=[\"number\", \"markdown\", \"markdown\", \"number\"]\n",
137
+ " )\n",
138
  " with gr.Row():\n",
139
  " data_run = gr.Button(\"Refresh\")\n",
140
  " data_run.click(\n",
141
  " get_submissions, inputs=gr.Variable(\"food\"), outputs=food_data\n",
142
  " )\n",
143
+ " with gr.TabItem(\"Landscape πŸ”\"):\n",
144
  " with gr.Row():\n",
145
+ " landscape_data = gr.components.Dataframe(\n",
146
+ " type=\"pandas\", datatype=[\"number\", \"markdown\", \"markdown\", \"number\"]\n",
147
+ " )\n",
148
  " with gr.Row():\n",
149
  " data_run = gr.Button(\"Refresh\")\n",
150
  " data_run.click(\n",
151
+ " get_submissions,\n",
152
+ " inputs=gr.Variable(\"landscape\"),\n",
153
+ " outputs=landscape_data,\n",
154
  " )\n",
155
+ " with gr.TabItem(\"Wilcard πŸ”₯\"):\n",
156
  " with gr.Row():\n",
157
+ " wildcard_data = gr.components.Dataframe(\n",
158
+ " type=\"pandas\", datatype=[\"number\", \"markdown\", \"markdown\", \"number\"]\n",
159
+ " )\n",
160
  " with gr.Row():\n",
161
  " data_run = gr.Button(\"Refresh\")\n",
162
  " data_run.click(\n",
 
177
  },
178
  {
179
  "cell_type": "code",
180
+ "execution_count": 110,
181
  "id": "17ff7d33-0c9a-4ca0-bb7b-ba1661063035",
182
  "metadata": {},
183
  "outputs": [
 
185
  "name": "stdout",
186
  "output_type": "stream",
187
  "text": [
188
+ "Closing server running on port: 7889\n"
189
  ]
190
  }
191
  ],
 
195
  },
196
  {
197
  "cell_type": "code",
198
+ "execution_count": 84,
199
  "id": "339fee32-8a83-435d-b882-55b5f0994774",
200
  "metadata": {},
201
  "outputs": [],
app.py CHANGED
@@ -1,7 +1,7 @@
1
  # AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
2
 
3
  # %% auto 0
4
- __all__ = ['block', 'get_submissions']
5
 
6
  # %% app.ipynb 0
7
  import gradio as gr
@@ -9,16 +9,29 @@ import pandas as pd
9
  from huggingface_hub import list_models
10
 
11
  # %% app.ipynb 1
 
 
 
 
 
 
 
 
 
 
 
 
12
  def get_submissions(category):
13
  submissions = list_models(filter=["dreambooth-hackathon", category], full=True)
14
  leaderboard_models = []
15
 
16
  for submission in submissions:
17
  # user, model, likes
 
18
  leaderboard_models.append(
19
  (
20
- submission.id.split("/")[0],
21
- submission.id.split("/")[-1],
22
  submission.likes,
23
  )
24
  )
@@ -28,47 +41,64 @@ def get_submissions(category):
28
  df.insert(0, "Rank", list(range(1, len(df) + 1)))
29
  return df
30
 
31
- # %% app.ipynb 2
32
  block = gr.Blocks()
33
 
34
  with block:
35
- gr.Markdown("hi")
 
 
 
 
 
36
  with gr.Tabs():
37
- with gr.TabItem("Animal"):
38
  with gr.Row():
39
- animal_data = gr.outputs.Dataframe(type="pandas")
 
 
40
  with gr.Row():
41
  data_run = gr.Button("Refresh")
42
  data_run.click(
43
  get_submissions, inputs=gr.Variable("animal"), outputs=animal_data
44
  )
45
- with gr.TabItem("Science"):
46
  with gr.Row():
47
- science_data = gr.outputs.Dataframe(type="pandas")
 
 
48
  with gr.Row():
49
  data_run = gr.Button("Refresh")
50
  data_run.click(
51
  get_submissions, inputs=gr.Variable("science"), outputs=science_data
52
  )
53
- with gr.TabItem("Food"):
54
  with gr.Row():
55
- food_data = gr.outputs.Dataframe(type="pandas")
 
 
56
  with gr.Row():
57
  data_run = gr.Button("Refresh")
58
  data_run.click(
59
  get_submissions, inputs=gr.Variable("food"), outputs=food_data
60
  )
61
- with gr.TabItem("Landscape"):
62
  with gr.Row():
63
- landscape_data = gr.outputs.Dataframe(type="pandas")
 
 
64
  with gr.Row():
65
  data_run = gr.Button("Refresh")
66
  data_run.click(
67
- get_submissions, inputs=gr.Variable("landscape"), outputs=landscape_data
 
 
68
  )
69
- with gr.TabItem("Wilcard"):
70
  with gr.Row():
71
- wildcard_data = gr.outputs.Dataframe(type="pandas")
 
 
72
  with gr.Row():
73
  data_run = gr.Button("Refresh")
74
  data_run.click(
 
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
 
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
  )
 
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!
52
+ """
53
+ )
54
  with gr.Tabs():
55
+ with gr.TabItem("Animal 🐨"):
56
  with gr.Row():
57
+ animal_data = gr.components.Dataframe(
58
+ type="pandas", datatype=["number", "markdown", "markdown", "number"]
59
+ )
60
  with gr.Row():
61
  data_run = gr.Button("Refresh")
62
  data_run.click(
63
  get_submissions, inputs=gr.Variable("animal"), outputs=animal_data
64
  )
65
+ with gr.TabItem("Science πŸ”¬"):
66
  with gr.Row():
67
+ science_data = gr.components.Dataframe(
68
+ type="pandas", datatype=["number", "markdown", "markdown", "number"]
69
+ )
70
  with gr.Row():
71
  data_run = gr.Button("Refresh")
72
  data_run.click(
73
  get_submissions, inputs=gr.Variable("science"), outputs=science_data
74
  )
75
+ with gr.TabItem("Food πŸ”"):
76
  with gr.Row():
77
+ food_data = gr.components.Dataframe(
78
+ type="pandas", datatype=["number", "markdown", "markdown", "number"]
79
+ )
80
  with gr.Row():
81
  data_run = gr.Button("Refresh")
82
  data_run.click(
83
  get_submissions, inputs=gr.Variable("food"), outputs=food_data
84
  )
85
+ with gr.TabItem("Landscape πŸ”"):
86
  with gr.Row():
87
+ landscape_data = gr.components.Dataframe(
88
+ type="pandas", datatype=["number", "markdown", "markdown", "number"]
89
+ )
90
  with gr.Row():
91
  data_run = gr.Button("Refresh")
92
  data_run.click(
93
+ get_submissions,
94
+ inputs=gr.Variable("landscape"),
95
+ outputs=landscape_data,
96
  )
97
+ with gr.TabItem("Wilcard πŸ”₯"):
98
  with gr.Row():
99
+ wildcard_data = gr.components.Dataframe(
100
+ type="pandas", datatype=["number", "markdown", "markdown", "number"]
101
+ )
102
  with gr.Row():
103
  data_run = gr.Button("Refresh")
104
  data_run.click(