Benjamin Coman commited on
Commit
7656535
1 Parent(s): eab9286

Added app, model and examples.

Browse files
app.py CHANGED
@@ -1,7 +1,377 @@
1
- import gradio as gr
2
-
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
-
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "id": "1587b6c6",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "from fastai.vision.all import *\n",
11
+ "import gradio as gr\n",
12
+ "\n",
13
+ "#def is_cat(x): return x[0].isupper()\n",
14
+ "\n",
15
+ "learn = load_learner('watersports.pkl')\n",
16
+ "#learn.dls.vocab"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": 27,
22
+ "id": "066f65b3",
23
+ "metadata": {},
24
+ "outputs": [
25
+ {
26
+ "name": "stdout",
27
+ "output_type": "stream",
28
+ "text": [
29
+ "Running on local URL: http://127.0.0.1:7873/\n",
30
+ "\n",
31
+ "To create a public link, set `share=True` in `launch()`.\n"
32
+ ]
33
+ },
34
+ {
35
+ "data": {
36
+ "text/plain": [
37
+ "(<fastapi.applications.FastAPI at 0x7f9a58a15a60>,\n",
38
+ " 'http://127.0.0.1:7873/',\n",
39
+ " None)"
40
+ ]
41
+ },
42
+ "execution_count": 27,
43
+ "metadata": {},
44
+ "output_type": "execute_result"
45
+ },
46
+ {
47
+ "data": {
48
+ "text/html": [
49
+ "\n",
50
+ "<style>\n",
51
+ " /* Turns off some styling */\n",
52
+ " progress {\n",
53
+ " /* gets rid of default border in Firefox and Opera. */\n",
54
+ " border: none;\n",
55
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
56
+ " background-size: auto;\n",
57
+ " }\n",
58
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
59
+ " background: #F44336;\n",
60
+ " }\n",
61
+ "</style>\n"
62
+ ],
63
+ "text/plain": [
64
+ "<IPython.core.display.HTML object>"
65
+ ]
66
+ },
67
+ "metadata": {},
68
+ "output_type": "display_data"
69
+ },
70
+ {
71
+ "data": {
72
+ "text/html": [],
73
+ "text/plain": [
74
+ "<IPython.core.display.HTML object>"
75
+ ]
76
+ },
77
+ "metadata": {},
78
+ "output_type": "display_data"
79
+ },
80
+ {
81
+ "data": {
82
+ "text/html": [
83
+ "\n",
84
+ "<style>\n",
85
+ " /* Turns off some styling */\n",
86
+ " progress {\n",
87
+ " /* gets rid of default border in Firefox and Opera. */\n",
88
+ " border: none;\n",
89
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
90
+ " background-size: auto;\n",
91
+ " }\n",
92
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
93
+ " background: #F44336;\n",
94
+ " }\n",
95
+ "</style>\n"
96
+ ],
97
+ "text/plain": [
98
+ "<IPython.core.display.HTML object>"
99
+ ]
100
+ },
101
+ "metadata": {},
102
+ "output_type": "display_data"
103
+ },
104
+ {
105
+ "data": {
106
+ "text/html": [],
107
+ "text/plain": [
108
+ "<IPython.core.display.HTML object>"
109
+ ]
110
+ },
111
+ "metadata": {},
112
+ "output_type": "display_data"
113
+ },
114
+ {
115
+ "data": {
116
+ "text/html": [
117
+ "\n",
118
+ "<style>\n",
119
+ " /* Turns off some styling */\n",
120
+ " progress {\n",
121
+ " /* gets rid of default border in Firefox and Opera. */\n",
122
+ " border: none;\n",
123
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
124
+ " background-size: auto;\n",
125
+ " }\n",
126
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
127
+ " background: #F44336;\n",
128
+ " }\n",
129
+ "</style>\n"
130
+ ],
131
+ "text/plain": [
132
+ "<IPython.core.display.HTML object>"
133
+ ]
134
+ },
135
+ "metadata": {},
136
+ "output_type": "display_data"
137
+ },
138
+ {
139
+ "data": {
140
+ "text/html": [],
141
+ "text/plain": [
142
+ "<IPython.core.display.HTML object>"
143
+ ]
144
+ },
145
+ "metadata": {},
146
+ "output_type": "display_data"
147
+ },
148
+ {
149
+ "data": {
150
+ "text/html": [
151
+ "\n",
152
+ "<style>\n",
153
+ " /* Turns off some styling */\n",
154
+ " progress {\n",
155
+ " /* gets rid of default border in Firefox and Opera. */\n",
156
+ " border: none;\n",
157
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
158
+ " background-size: auto;\n",
159
+ " }\n",
160
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
161
+ " background: #F44336;\n",
162
+ " }\n",
163
+ "</style>\n"
164
+ ],
165
+ "text/plain": [
166
+ "<IPython.core.display.HTML object>"
167
+ ]
168
+ },
169
+ "metadata": {},
170
+ "output_type": "display_data"
171
+ },
172
+ {
173
+ "data": {
174
+ "text/html": [],
175
+ "text/plain": [
176
+ "<IPython.core.display.HTML object>"
177
+ ]
178
+ },
179
+ "metadata": {},
180
+ "output_type": "display_data"
181
+ },
182
+ {
183
+ "data": {
184
+ "text/html": [
185
+ "\n",
186
+ "<style>\n",
187
+ " /* Turns off some styling */\n",
188
+ " progress {\n",
189
+ " /* gets rid of default border in Firefox and Opera. */\n",
190
+ " border: none;\n",
191
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
192
+ " background-size: auto;\n",
193
+ " }\n",
194
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
195
+ " background: #F44336;\n",
196
+ " }\n",
197
+ "</style>\n"
198
+ ],
199
+ "text/plain": [
200
+ "<IPython.core.display.HTML object>"
201
+ ]
202
+ },
203
+ "metadata": {},
204
+ "output_type": "display_data"
205
+ },
206
+ {
207
+ "data": {
208
+ "text/html": [],
209
+ "text/plain": [
210
+ "<IPython.core.display.HTML object>"
211
+ ]
212
+ },
213
+ "metadata": {},
214
+ "output_type": "display_data"
215
+ },
216
+ {
217
+ "data": {
218
+ "text/html": [
219
+ "\n",
220
+ "<style>\n",
221
+ " /* Turns off some styling */\n",
222
+ " progress {\n",
223
+ " /* gets rid of default border in Firefox and Opera. */\n",
224
+ " border: none;\n",
225
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
226
+ " background-size: auto;\n",
227
+ " }\n",
228
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
229
+ " background: #F44336;\n",
230
+ " }\n",
231
+ "</style>\n"
232
+ ],
233
+ "text/plain": [
234
+ "<IPython.core.display.HTML object>"
235
+ ]
236
+ },
237
+ "metadata": {},
238
+ "output_type": "display_data"
239
+ },
240
+ {
241
+ "data": {
242
+ "text/html": [],
243
+ "text/plain": [
244
+ "<IPython.core.display.HTML object>"
245
+ ]
246
+ },
247
+ "metadata": {},
248
+ "output_type": "display_data"
249
+ },
250
+ {
251
+ "data": {
252
+ "text/html": [
253
+ "\n",
254
+ "<style>\n",
255
+ " /* Turns off some styling */\n",
256
+ " progress {\n",
257
+ " /* gets rid of default border in Firefox and Opera. */\n",
258
+ " border: none;\n",
259
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
260
+ " background-size: auto;\n",
261
+ " }\n",
262
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
263
+ " background: #F44336;\n",
264
+ " }\n",
265
+ "</style>\n"
266
+ ],
267
+ "text/plain": [
268
+ "<IPython.core.display.HTML object>"
269
+ ]
270
+ },
271
+ "metadata": {},
272
+ "output_type": "display_data"
273
+ },
274
+ {
275
+ "data": {
276
+ "text/html": [],
277
+ "text/plain": [
278
+ "<IPython.core.display.HTML object>"
279
+ ]
280
+ },
281
+ "metadata": {},
282
+ "output_type": "display_data"
283
+ },
284
+ {
285
+ "data": {
286
+ "text/html": [
287
+ "\n",
288
+ "<style>\n",
289
+ " /* Turns off some styling */\n",
290
+ " progress {\n",
291
+ " /* gets rid of default border in Firefox and Opera. */\n",
292
+ " border: none;\n",
293
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
294
+ " background-size: auto;\n",
295
+ " }\n",
296
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
297
+ " background: #F44336;\n",
298
+ " }\n",
299
+ "</style>\n"
300
+ ],
301
+ "text/plain": [
302
+ "<IPython.core.display.HTML object>"
303
+ ]
304
+ },
305
+ "metadata": {},
306
+ "output_type": "display_data"
307
+ },
308
+ {
309
+ "data": {
310
+ "text/html": [],
311
+ "text/plain": [
312
+ "<IPython.core.display.HTML object>"
313
+ ]
314
+ },
315
+ "metadata": {},
316
+ "output_type": "display_data"
317
+ }
318
+ ],
319
+ "source": [
320
+ "categories = learn.dls.vocab\n",
321
+ "\n",
322
+ "def classify_image(img):\n",
323
+ " pred,idx,probs = learn.predict(img)\n",
324
+ " return( dict(zip(categories, map(float,probs))))\n",
325
+ "\n",
326
+ "image = gr.inputs.Image(shape=(192,192))\n",
327
+ "label = gr.outputs.Label()\n",
328
+ "examples = './examples'\n",
329
+ "\n",
330
+ "iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
331
+ "iface.launch(inline=False)"
332
+ ]
333
+ },
334
+ {
335
+ "cell_type": "code",
336
+ "execution_count": null,
337
+ "id": "5c2b5daa",
338
+ "metadata": {},
339
+ "outputs": [],
340
+ "source": []
341
+ }
342
+ ],
343
+ "metadata": {
344
+ "kernelspec": {
345
+ "display_name": "Python [conda env:root] *",
346
+ "language": "python",
347
+ "name": "conda-root-py"
348
+ },
349
+ "language_info": {
350
+ "codemirror_mode": {
351
+ "name": "ipython",
352
+ "version": 3
353
+ },
354
+ "file_extension": ".py",
355
+ "mimetype": "text/x-python",
356
+ "name": "python",
357
+ "nbconvert_exporter": "python",
358
+ "pygments_lexer": "ipython3",
359
+ "version": "3.9.10"
360
+ },
361
+ "toc": {
362
+ "base_numbering": 1,
363
+ "nav_menu": {},
364
+ "number_sections": true,
365
+ "sideBar": true,
366
+ "skip_h1_title": false,
367
+ "title_cell": "Table of Contents",
368
+ "title_sidebar": "Contents",
369
+ "toc_cell": false,
370
+ "toc_position": {},
371
+ "toc_section_display": true,
372
+ "toc_window_display": false
373
+ }
374
+ },
375
+ "nbformat": 4,
376
+ "nbformat_minor": 5
377
+ }
applocal.ipynb ADDED
@@ -0,0 +1,377 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "id": "1587b6c6",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "from fastai.vision.all import *\n",
11
+ "import gradio as gr\n",
12
+ "\n",
13
+ "#def is_cat(x): return x[0].isupper()\n",
14
+ "\n",
15
+ "learn = load_learner('watersports.pkl')\n",
16
+ "#learn.dls.vocab"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": 27,
22
+ "id": "066f65b3",
23
+ "metadata": {},
24
+ "outputs": [
25
+ {
26
+ "name": "stdout",
27
+ "output_type": "stream",
28
+ "text": [
29
+ "Running on local URL: http://127.0.0.1:7873/\n",
30
+ "\n",
31
+ "To create a public link, set `share=True` in `launch()`.\n"
32
+ ]
33
+ },
34
+ {
35
+ "data": {
36
+ "text/plain": [
37
+ "(<fastapi.applications.FastAPI at 0x7f9a58a15a60>,\n",
38
+ " 'http://127.0.0.1:7873/',\n",
39
+ " None)"
40
+ ]
41
+ },
42
+ "execution_count": 27,
43
+ "metadata": {},
44
+ "output_type": "execute_result"
45
+ },
46
+ {
47
+ "data": {
48
+ "text/html": [
49
+ "\n",
50
+ "<style>\n",
51
+ " /* Turns off some styling */\n",
52
+ " progress {\n",
53
+ " /* gets rid of default border in Firefox and Opera. */\n",
54
+ " border: none;\n",
55
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
56
+ " background-size: auto;\n",
57
+ " }\n",
58
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
59
+ " background: #F44336;\n",
60
+ " }\n",
61
+ "</style>\n"
62
+ ],
63
+ "text/plain": [
64
+ "<IPython.core.display.HTML object>"
65
+ ]
66
+ },
67
+ "metadata": {},
68
+ "output_type": "display_data"
69
+ },
70
+ {
71
+ "data": {
72
+ "text/html": [],
73
+ "text/plain": [
74
+ "<IPython.core.display.HTML object>"
75
+ ]
76
+ },
77
+ "metadata": {},
78
+ "output_type": "display_data"
79
+ },
80
+ {
81
+ "data": {
82
+ "text/html": [
83
+ "\n",
84
+ "<style>\n",
85
+ " /* Turns off some styling */\n",
86
+ " progress {\n",
87
+ " /* gets rid of default border in Firefox and Opera. */\n",
88
+ " border: none;\n",
89
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
90
+ " background-size: auto;\n",
91
+ " }\n",
92
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
93
+ " background: #F44336;\n",
94
+ " }\n",
95
+ "</style>\n"
96
+ ],
97
+ "text/plain": [
98
+ "<IPython.core.display.HTML object>"
99
+ ]
100
+ },
101
+ "metadata": {},
102
+ "output_type": "display_data"
103
+ },
104
+ {
105
+ "data": {
106
+ "text/html": [],
107
+ "text/plain": [
108
+ "<IPython.core.display.HTML object>"
109
+ ]
110
+ },
111
+ "metadata": {},
112
+ "output_type": "display_data"
113
+ },
114
+ {
115
+ "data": {
116
+ "text/html": [
117
+ "\n",
118
+ "<style>\n",
119
+ " /* Turns off some styling */\n",
120
+ " progress {\n",
121
+ " /* gets rid of default border in Firefox and Opera. */\n",
122
+ " border: none;\n",
123
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
124
+ " background-size: auto;\n",
125
+ " }\n",
126
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
127
+ " background: #F44336;\n",
128
+ " }\n",
129
+ "</style>\n"
130
+ ],
131
+ "text/plain": [
132
+ "<IPython.core.display.HTML object>"
133
+ ]
134
+ },
135
+ "metadata": {},
136
+ "output_type": "display_data"
137
+ },
138
+ {
139
+ "data": {
140
+ "text/html": [],
141
+ "text/plain": [
142
+ "<IPython.core.display.HTML object>"
143
+ ]
144
+ },
145
+ "metadata": {},
146
+ "output_type": "display_data"
147
+ },
148
+ {
149
+ "data": {
150
+ "text/html": [
151
+ "\n",
152
+ "<style>\n",
153
+ " /* Turns off some styling */\n",
154
+ " progress {\n",
155
+ " /* gets rid of default border in Firefox and Opera. */\n",
156
+ " border: none;\n",
157
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
158
+ " background-size: auto;\n",
159
+ " }\n",
160
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
161
+ " background: #F44336;\n",
162
+ " }\n",
163
+ "</style>\n"
164
+ ],
165
+ "text/plain": [
166
+ "<IPython.core.display.HTML object>"
167
+ ]
168
+ },
169
+ "metadata": {},
170
+ "output_type": "display_data"
171
+ },
172
+ {
173
+ "data": {
174
+ "text/html": [],
175
+ "text/plain": [
176
+ "<IPython.core.display.HTML object>"
177
+ ]
178
+ },
179
+ "metadata": {},
180
+ "output_type": "display_data"
181
+ },
182
+ {
183
+ "data": {
184
+ "text/html": [
185
+ "\n",
186
+ "<style>\n",
187
+ " /* Turns off some styling */\n",
188
+ " progress {\n",
189
+ " /* gets rid of default border in Firefox and Opera. */\n",
190
+ " border: none;\n",
191
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
192
+ " background-size: auto;\n",
193
+ " }\n",
194
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
195
+ " background: #F44336;\n",
196
+ " }\n",
197
+ "</style>\n"
198
+ ],
199
+ "text/plain": [
200
+ "<IPython.core.display.HTML object>"
201
+ ]
202
+ },
203
+ "metadata": {},
204
+ "output_type": "display_data"
205
+ },
206
+ {
207
+ "data": {
208
+ "text/html": [],
209
+ "text/plain": [
210
+ "<IPython.core.display.HTML object>"
211
+ ]
212
+ },
213
+ "metadata": {},
214
+ "output_type": "display_data"
215
+ },
216
+ {
217
+ "data": {
218
+ "text/html": [
219
+ "\n",
220
+ "<style>\n",
221
+ " /* Turns off some styling */\n",
222
+ " progress {\n",
223
+ " /* gets rid of default border in Firefox and Opera. */\n",
224
+ " border: none;\n",
225
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
226
+ " background-size: auto;\n",
227
+ " }\n",
228
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
229
+ " background: #F44336;\n",
230
+ " }\n",
231
+ "</style>\n"
232
+ ],
233
+ "text/plain": [
234
+ "<IPython.core.display.HTML object>"
235
+ ]
236
+ },
237
+ "metadata": {},
238
+ "output_type": "display_data"
239
+ },
240
+ {
241
+ "data": {
242
+ "text/html": [],
243
+ "text/plain": [
244
+ "<IPython.core.display.HTML object>"
245
+ ]
246
+ },
247
+ "metadata": {},
248
+ "output_type": "display_data"
249
+ },
250
+ {
251
+ "data": {
252
+ "text/html": [
253
+ "\n",
254
+ "<style>\n",
255
+ " /* Turns off some styling */\n",
256
+ " progress {\n",
257
+ " /* gets rid of default border in Firefox and Opera. */\n",
258
+ " border: none;\n",
259
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
260
+ " background-size: auto;\n",
261
+ " }\n",
262
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
263
+ " background: #F44336;\n",
264
+ " }\n",
265
+ "</style>\n"
266
+ ],
267
+ "text/plain": [
268
+ "<IPython.core.display.HTML object>"
269
+ ]
270
+ },
271
+ "metadata": {},
272
+ "output_type": "display_data"
273
+ },
274
+ {
275
+ "data": {
276
+ "text/html": [],
277
+ "text/plain": [
278
+ "<IPython.core.display.HTML object>"
279
+ ]
280
+ },
281
+ "metadata": {},
282
+ "output_type": "display_data"
283
+ },
284
+ {
285
+ "data": {
286
+ "text/html": [
287
+ "\n",
288
+ "<style>\n",
289
+ " /* Turns off some styling */\n",
290
+ " progress {\n",
291
+ " /* gets rid of default border in Firefox and Opera. */\n",
292
+ " border: none;\n",
293
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
294
+ " background-size: auto;\n",
295
+ " }\n",
296
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
297
+ " background: #F44336;\n",
298
+ " }\n",
299
+ "</style>\n"
300
+ ],
301
+ "text/plain": [
302
+ "<IPython.core.display.HTML object>"
303
+ ]
304
+ },
305
+ "metadata": {},
306
+ "output_type": "display_data"
307
+ },
308
+ {
309
+ "data": {
310
+ "text/html": [],
311
+ "text/plain": [
312
+ "<IPython.core.display.HTML object>"
313
+ ]
314
+ },
315
+ "metadata": {},
316
+ "output_type": "display_data"
317
+ }
318
+ ],
319
+ "source": [
320
+ "categories = learn.dls.vocab\n",
321
+ "\n",
322
+ "def classify_image(img):\n",
323
+ " pred,idx,probs = learn.predict(img)\n",
324
+ " return( dict(zip(categories, map(float,probs))))\n",
325
+ "\n",
326
+ "image = gr.inputs.Image(shape=(192,192))\n",
327
+ "label = gr.outputs.Label()\n",
328
+ "examples = './examples'\n",
329
+ "\n",
330
+ "iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
331
+ "iface.launch(inline=False)"
332
+ ]
333
+ },
334
+ {
335
+ "cell_type": "code",
336
+ "execution_count": null,
337
+ "id": "5c2b5daa",
338
+ "metadata": {},
339
+ "outputs": [],
340
+ "source": []
341
+ }
342
+ ],
343
+ "metadata": {
344
+ "kernelspec": {
345
+ "display_name": "Python [conda env:root] *",
346
+ "language": "python",
347
+ "name": "conda-root-py"
348
+ },
349
+ "language_info": {
350
+ "codemirror_mode": {
351
+ "name": "ipython",
352
+ "version": 3
353
+ },
354
+ "file_extension": ".py",
355
+ "mimetype": "text/x-python",
356
+ "name": "python",
357
+ "nbconvert_exporter": "python",
358
+ "pygments_lexer": "ipython3",
359
+ "version": "3.9.10"
360
+ },
361
+ "toc": {
362
+ "base_numbering": 1,
363
+ "nav_menu": {},
364
+ "number_sections": true,
365
+ "sideBar": true,
366
+ "skip_h1_title": false,
367
+ "title_cell": "Table of Contents",
368
+ "title_sidebar": "Contents",
369
+ "toc_cell": false,
370
+ "toc_position": {},
371
+ "toc_section_display": true,
372
+ "toc_window_display": false
373
+ }
374
+ },
375
+ "nbformat": 4,
376
+ "nbformat_minor": 5
377
+ }
examples/aqua-aerobics.jpg ADDED
examples/barefoot.jpg ADDED
examples/boating.jpg ADDED
examples/bodyboarding.jpg ADDED
examples/bodysurfing.jpg ADDED
examples/canoe-polo.jpg ADDED
examples/cave-diving.jpg ADDED
examples/cruising.jpg ADDED
examples/dragon-boat-racing.jpg ADDED
examples/fin-swimming.jpg ADDED
examples/fishing.jpg ADDED
examples/flyboard.jpg ADDED
examples/free-diving.jpg ADDED
examples/ice-diving.jpg ADDED
examples/jet-boat-racing.jpg ADDED
examples/kayaking.jpg ADDED
examples/kite-boarding.jpg ADDED
examples/mermaiding.jpg ADDED
examples/outrigger.jpg ADDED
examples/paddleboarding.jpg ADDED
examples/parasailing.jpg ADDED
examples/platform-diving.jpg ADDED
examples/rowing.jpg ADDED
examples/sailing.jpg ADDED
examples/scuba-diving.jpg ADDED
examples/snorkeling.jpg ADDED
examples/spear-fishing.jpg ADDED
examples/stone-skipping.jpg ADDED
examples/surfing.jpg ADDED
examples/swimming.jpg ADDED
examples/synchronised-swimming.jpg ADDED
examples/tubing.jpg ADDED
examples/water-polo.jpg ADDED
examples/water-skiing.jpg ADDED
examples/white-water-rafting.jpg ADDED
examples/wreck-diving.jpg ADDED
watersports.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:65f4424790752f60709c434311a9f56c7dd46f46b976d34a05bc7b95be799323
3
+ size 47144299