Spaces:
Sleeping
Sleeping
danielmartinec
commited on
Commit
•
87b7915
1
Parent(s):
168be6a
Using bear_multicat.pkl
Browse files- app.ipynb +145 -52
- app.py +6 -5
- app_ipywidgets.ipynb +0 -0
- images/einstein.png +0 -0
- images/text.png +0 -0
- requirements.txt +2 -1
app.ipynb
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
},
|
13 |
{
|
14 |
"cell_type": "code",
|
15 |
-
"execution_count":
|
16 |
"id": "eea0a34c-610b-4cda-a0d0-d33fc5a4d8c6",
|
17 |
"metadata": {},
|
18 |
"outputs": [],
|
@@ -24,7 +24,7 @@
|
|
24 |
},
|
25 |
{
|
26 |
"cell_type": "code",
|
27 |
-
"execution_count":
|
28 |
"id": "56b1b84c-124c-4a00-b3a9-825a73b3176c",
|
29 |
"metadata": {},
|
30 |
"outputs": [
|
@@ -36,31 +36,48 @@
|
|
36 |
"PILImage mode=RGB size=192x128"
|
37 |
]
|
38 |
},
|
39 |
-
"execution_count":
|
40 |
"metadata": {},
|
41 |
"output_type": "execute_result"
|
42 |
}
|
43 |
],
|
44 |
"source": [
|
45 |
-
"im = PILImage.create('grizzly.jpg')\n",
|
46 |
"im.thumbnail((192,192))\n",
|
47 |
"im"
|
48 |
]
|
49 |
},
|
50 |
{
|
51 |
"cell_type": "code",
|
52 |
-
"execution_count":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
"id": "64fb2afb-d5ae-4fe9-8ede-f269fc731277",
|
54 |
"metadata": {},
|
55 |
"outputs": [],
|
56 |
"source": [
|
57 |
"#|export\n",
|
58 |
-
"learn = load_learner('export.pkl')"
|
59 |
]
|
60 |
},
|
61 |
{
|
62 |
"cell_type": "code",
|
63 |
-
"execution_count":
|
64 |
"id": "458d4f3f-44c7-40d1-b3f4-ec32505bcd3e",
|
65 |
"metadata": {},
|
66 |
"outputs": [
|
@@ -104,10 +121,12 @@
|
|
104 |
{
|
105 |
"data": {
|
106 |
"text/plain": [
|
107 |
-
"(
|
|
|
|
|
108 |
]
|
109 |
},
|
110 |
-
"execution_count":
|
111 |
"metadata": {},
|
112 |
"output_type": "execute_result"
|
113 |
}
|
@@ -118,7 +137,7 @@
|
|
118 |
},
|
119 |
{
|
120 |
"cell_type": "code",
|
121 |
-
"execution_count":
|
122 |
"id": "a8b789a2-2333-44ad-b786-ba8d85cc9225",
|
123 |
"metadata": {},
|
124 |
"outputs": [],
|
@@ -133,7 +152,7 @@
|
|
133 |
},
|
134 |
{
|
135 |
"cell_type": "code",
|
136 |
-
"execution_count":
|
137 |
"id": "1faf012d-8159-4aae-b3a9-9c17751fc187",
|
138 |
"metadata": {},
|
139 |
"outputs": [
|
@@ -177,12 +196,12 @@
|
|
177 |
{
|
178 |
"data": {
|
179 |
"text/plain": [
|
180 |
-
"{'
|
181 |
-
" '
|
182 |
-
" 'teddy': 0.
|
183 |
]
|
184 |
},
|
185 |
-
"execution_count":
|
186 |
"metadata": {},
|
187 |
"output_type": "execute_result"
|
188 |
}
|
@@ -193,7 +212,7 @@
|
|
193 |
},
|
194 |
{
|
195 |
"cell_type": "code",
|
196 |
-
"execution_count":
|
197 |
"id": "5e10c092-c82d-4d85-8cb9-c7dc791269fc",
|
198 |
"metadata": {},
|
199 |
"outputs": [
|
@@ -201,7 +220,7 @@
|
|
201 |
"name": "stdout",
|
202 |
"output_type": "stream",
|
203 |
"text": [
|
204 |
-
"Running on local URL: http://127.0.0.1:
|
205 |
"\n",
|
206 |
"To create a public link, set `share=True` in `launch()`.\n"
|
207 |
]
|
@@ -210,7 +229,7 @@
|
|
210 |
"data": {
|
211 |
"text/plain": []
|
212 |
},
|
213 |
-
"execution_count":
|
214 |
"metadata": {},
|
215 |
"output_type": "execute_result"
|
216 |
},
|
@@ -241,6 +260,80 @@
|
|
241 |
"metadata": {},
|
242 |
"output_type": "display_data"
|
243 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
{
|
245 |
"data": {
|
246 |
"text/html": [],
|
@@ -256,7 +349,8 @@
|
|
256 |
"#|export\n",
|
257 |
"image = gr.Image(width=192, height=192)\n",
|
258 |
"label = gr.Label()\n",
|
259 |
-
"examples = ['images/grizzly.jpg', 'images/black.jpg', 'images/teddy.jpg'
|
|
|
260 |
"\n",
|
261 |
"intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
|
262 |
"intf.launch(inline=False)"
|
@@ -264,7 +358,7 @@
|
|
264 |
},
|
265 |
{
|
266 |
"cell_type": "code",
|
267 |
-
"execution_count":
|
268 |
"id": "2017b1ba-f8d3-4a1d-98da-f52ce147df14",
|
269 |
"metadata": {},
|
270 |
"outputs": [],
|
@@ -274,7 +368,7 @@
|
|
274 |
},
|
275 |
{
|
276 |
"cell_type": "code",
|
277 |
-
"execution_count":
|
278 |
"id": "9e1976f1-79bb-496a-85e0-107766999c62",
|
279 |
"metadata": {},
|
280 |
"outputs": [],
|
@@ -284,32 +378,41 @@
|
|
284 |
},
|
285 |
{
|
286 |
"cell_type": "code",
|
287 |
-
"execution_count":
|
288 |
-
"id": "ca8e3d8d-44ab-4d9b-be1b-62735cd85c63",
|
289 |
-
"metadata": {},
|
290 |
-
"outputs": [],
|
291 |
-
"source": [
|
292 |
-
"from nbdev.migrate import migrate_nb"
|
293 |
-
]
|
294 |
-
},
|
295 |
-
{
|
296 |
-
"cell_type": "code",
|
297 |
-
"execution_count": null,
|
298 |
"id": "098fb721-a743-4cb7-aebd-2b50c338371a",
|
299 |
"metadata": {},
|
300 |
"outputs": [
|
301 |
{
|
302 |
"data": {
|
303 |
"text/plain": [
|
304 |
-
"\u001b[0;31mSignature:\u001b[0m
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
"\u001b[0;31mSource:\u001b[0m \n",
|
306 |
-
"\u001b[0;32mdef\u001b[0m \u001b[
|
307 |
-
"\u001b[0;34m\u001b[0m \u001b[0;34m\"
|
308 |
-
"\u001b[0;34m\u001b[0m \u001b[
|
309 |
-
"\u001b[0;34m\u001b[0m \u001b[
|
310 |
-
"\u001b[0;34m\u001b[0m \u001b[0;
|
311 |
-
"\u001b[0;34m\u001b[0m \u001b[
|
312 |
-
"\u001b[0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
"\u001b[0;31mType:\u001b[0m function"
|
314 |
]
|
315 |
},
|
@@ -318,17 +421,7 @@
|
|
318 |
}
|
319 |
],
|
320 |
"source": [
|
321 |
-
"??
|
322 |
-
]
|
323 |
-
},
|
324 |
-
{
|
325 |
-
"cell_type": "code",
|
326 |
-
"execution_count": null,
|
327 |
-
"id": "021b2a42-4ddd-472d-8597-f689e777d7ba",
|
328 |
-
"metadata": {},
|
329 |
-
"outputs": [],
|
330 |
-
"source": [
|
331 |
-
"#migrate_nb('app.ipynb', overwrite=True)"
|
332 |
]
|
333 |
},
|
334 |
{
|
@@ -356,7 +449,7 @@
|
|
356 |
"name": "python",
|
357 |
"nbconvert_exporter": "python",
|
358 |
"pygments_lexer": "ipython3",
|
359 |
-
"version": "3.
|
360 |
}
|
361 |
},
|
362 |
"nbformat": 4,
|
|
|
12 |
},
|
13 |
{
|
14 |
"cell_type": "code",
|
15 |
+
"execution_count": 2,
|
16 |
"id": "eea0a34c-610b-4cda-a0d0-d33fc5a4d8c6",
|
17 |
"metadata": {},
|
18 |
"outputs": [],
|
|
|
24 |
},
|
25 |
{
|
26 |
"cell_type": "code",
|
27 |
+
"execution_count": 4,
|
28 |
"id": "56b1b84c-124c-4a00-b3a9-825a73b3176c",
|
29 |
"metadata": {},
|
30 |
"outputs": [
|
|
|
36 |
"PILImage mode=RGB size=192x128"
|
37 |
]
|
38 |
},
|
39 |
+
"execution_count": 4,
|
40 |
"metadata": {},
|
41 |
"output_type": "execute_result"
|
42 |
}
|
43 |
],
|
44 |
"source": [
|
45 |
+
"im = PILImage.create('images/grizzly.jpg')\n",
|
46 |
"im.thumbnail((192,192))\n",
|
47 |
"im"
|
48 |
]
|
49 |
},
|
50 |
{
|
51 |
"cell_type": "code",
|
52 |
+
"execution_count": 6,
|
53 |
+
"id": "efc4a6b6-3351-4679-8d43-6b05895b38a9",
|
54 |
+
"metadata": {},
|
55 |
+
"outputs": [],
|
56 |
+
"source": [
|
57 |
+
"# Copied from https://n90l9ahmyv.clg07azjl.paperspacegradient.com/lab/tree/bear_multicat.ipynb\n",
|
58 |
+
"\n",
|
59 |
+
"# from parent_label\n",
|
60 |
+
"def get_y(o):\n",
|
61 |
+
" parent_name = Path(o).parent.name\n",
|
62 |
+
" if parent_name in bear_types:\n",
|
63 |
+
" return [parent_name]\n",
|
64 |
+
" return []"
|
65 |
+
]
|
66 |
+
},
|
67 |
+
{
|
68 |
+
"cell_type": "code",
|
69 |
+
"execution_count": 7,
|
70 |
"id": "64fb2afb-d5ae-4fe9-8ede-f269fc731277",
|
71 |
"metadata": {},
|
72 |
"outputs": [],
|
73 |
"source": [
|
74 |
"#|export\n",
|
75 |
+
"learn = load_learner('bear_multicat.pkl') #'export.pkl')"
|
76 |
]
|
77 |
},
|
78 |
{
|
79 |
"cell_type": "code",
|
80 |
+
"execution_count": 8,
|
81 |
"id": "458d4f3f-44c7-40d1-b3f4-ec32505bcd3e",
|
82 |
"metadata": {},
|
83 |
"outputs": [
|
|
|
121 |
{
|
122 |
"data": {
|
123 |
"text/plain": [
|
124 |
+
"((#1) ['grizzly'],\n",
|
125 |
+
" tensor([False, True, False]),\n",
|
126 |
+
" tensor([1.2435e-04, 1.0000e+00, 9.2345e-04]))"
|
127 |
]
|
128 |
},
|
129 |
+
"execution_count": 8,
|
130 |
"metadata": {},
|
131 |
"output_type": "execute_result"
|
132 |
}
|
|
|
137 |
},
|
138 |
{
|
139 |
"cell_type": "code",
|
140 |
+
"execution_count": 9,
|
141 |
"id": "a8b789a2-2333-44ad-b786-ba8d85cc9225",
|
142 |
"metadata": {},
|
143 |
"outputs": [],
|
|
|
152 |
},
|
153 |
{
|
154 |
"cell_type": "code",
|
155 |
+
"execution_count": 10,
|
156 |
"id": "1faf012d-8159-4aae-b3a9-9c17751fc187",
|
157 |
"metadata": {},
|
158 |
"outputs": [
|
|
|
196 |
{
|
197 |
"data": {
|
198 |
"text/plain": [
|
199 |
+
"{'black': 0.0001243527658516541,\n",
|
200 |
+
" 'grizzly': 0.9999984502792358,\n",
|
201 |
+
" 'teddy': 0.0009234462631866336}"
|
202 |
]
|
203 |
},
|
204 |
+
"execution_count": 10,
|
205 |
"metadata": {},
|
206 |
"output_type": "execute_result"
|
207 |
}
|
|
|
212 |
},
|
213 |
{
|
214 |
"cell_type": "code",
|
215 |
+
"execution_count": 13,
|
216 |
"id": "5e10c092-c82d-4d85-8cb9-c7dc791269fc",
|
217 |
"metadata": {},
|
218 |
"outputs": [
|
|
|
220 |
"name": "stdout",
|
221 |
"output_type": "stream",
|
222 |
"text": [
|
223 |
+
"Running on local URL: http://127.0.0.1:7862\n",
|
224 |
"\n",
|
225 |
"To create a public link, set `share=True` in `launch()`.\n"
|
226 |
]
|
|
|
229 |
"data": {
|
230 |
"text/plain": []
|
231 |
},
|
232 |
+
"execution_count": 13,
|
233 |
"metadata": {},
|
234 |
"output_type": "execute_result"
|
235 |
},
|
|
|
260 |
"metadata": {},
|
261 |
"output_type": "display_data"
|
262 |
},
|
263 |
+
{
|
264 |
+
"data": {
|
265 |
+
"text/html": [],
|
266 |
+
"text/plain": [
|
267 |
+
"<IPython.core.display.HTML object>"
|
268 |
+
]
|
269 |
+
},
|
270 |
+
"metadata": {},
|
271 |
+
"output_type": "display_data"
|
272 |
+
},
|
273 |
+
{
|
274 |
+
"data": {
|
275 |
+
"text/html": [
|
276 |
+
"\n",
|
277 |
+
"<style>\n",
|
278 |
+
" /* Turns off some styling */\n",
|
279 |
+
" progress {\n",
|
280 |
+
" /* gets rid of default border in Firefox and Opera. */\n",
|
281 |
+
" border: none;\n",
|
282 |
+
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
283 |
+
" background-size: auto;\n",
|
284 |
+
" }\n",
|
285 |
+
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
286 |
+
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
287 |
+
" }\n",
|
288 |
+
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
289 |
+
" background: #F44336;\n",
|
290 |
+
" }\n",
|
291 |
+
"</style>\n"
|
292 |
+
],
|
293 |
+
"text/plain": [
|
294 |
+
"<IPython.core.display.HTML object>"
|
295 |
+
]
|
296 |
+
},
|
297 |
+
"metadata": {},
|
298 |
+
"output_type": "display_data"
|
299 |
+
},
|
300 |
+
{
|
301 |
+
"data": {
|
302 |
+
"text/html": [],
|
303 |
+
"text/plain": [
|
304 |
+
"<IPython.core.display.HTML object>"
|
305 |
+
]
|
306 |
+
},
|
307 |
+
"metadata": {},
|
308 |
+
"output_type": "display_data"
|
309 |
+
},
|
310 |
+
{
|
311 |
+
"data": {
|
312 |
+
"text/html": [
|
313 |
+
"\n",
|
314 |
+
"<style>\n",
|
315 |
+
" /* Turns off some styling */\n",
|
316 |
+
" progress {\n",
|
317 |
+
" /* gets rid of default border in Firefox and Opera. */\n",
|
318 |
+
" border: none;\n",
|
319 |
+
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
320 |
+
" background-size: auto;\n",
|
321 |
+
" }\n",
|
322 |
+
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
323 |
+
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
324 |
+
" }\n",
|
325 |
+
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
326 |
+
" background: #F44336;\n",
|
327 |
+
" }\n",
|
328 |
+
"</style>\n"
|
329 |
+
],
|
330 |
+
"text/plain": [
|
331 |
+
"<IPython.core.display.HTML object>"
|
332 |
+
]
|
333 |
+
},
|
334 |
+
"metadata": {},
|
335 |
+
"output_type": "display_data"
|
336 |
+
},
|
337 |
{
|
338 |
"data": {
|
339 |
"text/html": [],
|
|
|
349 |
"#|export\n",
|
350 |
"image = gr.Image(width=192, height=192)\n",
|
351 |
"label = gr.Label()\n",
|
352 |
+
"examples = ['images/grizzly.jpg', 'images/black.jpg', 'images/teddy.jpg',\n",
|
353 |
+
" 'images/text.png', 'images/einstein.png', 'images/dunno.jpg']\n",
|
354 |
"\n",
|
355 |
"intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
|
356 |
"intf.launch(inline=False)"
|
|
|
358 |
},
|
359 |
{
|
360 |
"cell_type": "code",
|
361 |
+
"execution_count": 14,
|
362 |
"id": "2017b1ba-f8d3-4a1d-98da-f52ce147df14",
|
363 |
"metadata": {},
|
364 |
"outputs": [],
|
|
|
368 |
},
|
369 |
{
|
370 |
"cell_type": "code",
|
371 |
+
"execution_count": 19,
|
372 |
"id": "9e1976f1-79bb-496a-85e0-107766999c62",
|
373 |
"metadata": {},
|
374 |
"outputs": [],
|
|
|
378 |
},
|
379 |
{
|
380 |
"cell_type": "code",
|
381 |
+
"execution_count": 16,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
382 |
"id": "098fb721-a743-4cb7-aebd-2b50c338371a",
|
383 |
"metadata": {},
|
384 |
"outputs": [
|
385 |
{
|
386 |
"data": {
|
387 |
"text/plain": [
|
388 |
+
"\u001b[0;31mSignature:\u001b[0m\n",
|
389 |
+
"\u001b[0mnbdev\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexport\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnb_export\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n",
|
390 |
+
"\u001b[0;34m\u001b[0m \u001b[0mnbname\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
|
391 |
+
"\u001b[0;34m\u001b[0m \u001b[0mlib_path\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
|
392 |
+
"\u001b[0;34m\u001b[0m \u001b[0mprocs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
|
393 |
+
"\u001b[0;34m\u001b[0m \u001b[0mdebug\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
|
394 |
+
"\u001b[0;34m\u001b[0m \u001b[0mmod_maker\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m<\u001b[0m\u001b[0;32mclass\u001b[0m \u001b[0;34m'nbdev.maker.ModuleMaker'\u001b[0m\u001b[0;34m>\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
|
395 |
+
"\u001b[0;34m\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
|
396 |
+
"\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
397 |
"\u001b[0;31mSource:\u001b[0m \n",
|
398 |
+
"\u001b[0;32mdef\u001b[0m \u001b[0mnb_export\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnbname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlib_path\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mprocs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdebug\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmod_maker\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mModuleMaker\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
|
399 |
+
"\u001b[0;34m\u001b[0m \u001b[0;34m\"Create module(s) from notebook\"\u001b[0m\u001b[0;34m\u001b[0m\n",
|
400 |
+
"\u001b[0;34m\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mlib_path\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mlib_path\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mget_config\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlib_path\u001b[0m\u001b[0;34m\u001b[0m\n",
|
401 |
+
"\u001b[0;34m\u001b[0m \u001b[0mexp\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mExportModuleProc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
|
402 |
+
"\u001b[0;34m\u001b[0m \u001b[0mnb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mNBProcessor\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnbname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mexp\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0mL\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mprocs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdebug\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdebug\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
|
403 |
+
"\u001b[0;34m\u001b[0m \u001b[0mnb\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mprocess\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
|
404 |
+
"\u001b[0;34m\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mmod\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mcells\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mexp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmodules\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
|
405 |
+
"\u001b[0;34m\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mfirst\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mo\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mcells\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mo\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcell_type\u001b[0m\u001b[0;34m==\u001b[0m\u001b[0;34m'code'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
|
406 |
+
"\u001b[0;34m\u001b[0m \u001b[0mall_cells\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mexp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0min_all\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mmod\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\n",
|
407 |
+
"\u001b[0;34m\u001b[0m \u001b[0mnm\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mifnone\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mgetattr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexp\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'default_exp'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmod\u001b[0m\u001b[0;34m==\u001b[0m\u001b[0;34m'#'\u001b[0m \u001b[0;32melse\u001b[0m \u001b[0mmod\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
|
408 |
+
"\u001b[0;34m\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mnm\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
|
409 |
+
"\u001b[0;34m\u001b[0m \u001b[0mwarn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf\"Notebook '{nbname}' uses `#|export` without `#|default_exp` cell.\\n\"\u001b[0m\u001b[0;34m\u001b[0m\n",
|
410 |
+
"\u001b[0;34m\u001b[0m \u001b[0;34m\"Note nbdev2 no longer supports nbdev1 syntax. Run `nbdev_migrate` to upgrade.\\n\"\u001b[0m\u001b[0;34m\u001b[0m\n",
|
411 |
+
"\u001b[0;34m\u001b[0m \u001b[0;34m\"See https://nbdev.fast.ai/getting_started.html for more information.\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
|
412 |
+
"\u001b[0;34m\u001b[0m \u001b[0;32mreturn\u001b[0m\u001b[0;34m\u001b[0m\n",
|
413 |
+
"\u001b[0;34m\u001b[0m \u001b[0mmm\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmod_maker\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdest\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mlib_path\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnm\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnb_path\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnbname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mis_new\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mbool\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mmod\u001b[0m\u001b[0;34m==\u001b[0m\u001b[0;34m'#'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
|
414 |
+
"\u001b[0;34m\u001b[0m \u001b[0mmm\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmake\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcells\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mall_cells\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlib_path\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mlib_path\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
415 |
+
"\u001b[0;31mFile:\u001b[0m ~/Library/Python/3.9/lib/python/site-packages/nbdev/export.py\n",
|
416 |
"\u001b[0;31mType:\u001b[0m function"
|
417 |
]
|
418 |
},
|
|
|
421 |
}
|
422 |
],
|
423 |
"source": [
|
424 |
+
"??nbdev.export.nb_export"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
425 |
]
|
426 |
},
|
427 |
{
|
|
|
449 |
"name": "python",
|
450 |
"nbconvert_exporter": "python",
|
451 |
"pygments_lexer": "ipython3",
|
452 |
+
"version": "3.9.6"
|
453 |
}
|
454 |
},
|
455 |
"nbformat": 4,
|
app.py
CHANGED
@@ -7,20 +7,21 @@ __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'classif
|
|
7 |
from fastai.vision.all import *
|
8 |
import gradio as gr
|
9 |
|
10 |
-
# %% ../app.ipynb
|
11 |
-
learn = load_learner('export.pkl')
|
12 |
|
13 |
-
# %% ../app.ipynb
|
14 |
categories = ('black', 'grizzly', 'teddy')
|
15 |
|
16 |
def classify_image(im):
|
17 |
pred, idx, probs = learn.predict(im)
|
18 |
return dict(zip(categories, map(float, probs)))
|
19 |
|
20 |
-
# %% ../app.ipynb
|
21 |
image = gr.Image(width=192, height=192)
|
22 |
label = gr.Label()
|
23 |
-
examples = ['images/grizzly.jpg', 'images/black.jpg', 'images/teddy.jpg',
|
|
|
24 |
|
25 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
26 |
intf.launch(inline=False)
|
|
|
7 |
from fastai.vision.all import *
|
8 |
import gradio as gr
|
9 |
|
10 |
+
# %% ../app.ipynb 4
|
11 |
+
learn = load_learner('bear_multicat.pkl') #'export.pkl')
|
12 |
|
13 |
+
# %% ../app.ipynb 6
|
14 |
categories = ('black', 'grizzly', 'teddy')
|
15 |
|
16 |
def classify_image(im):
|
17 |
pred, idx, probs = learn.predict(im)
|
18 |
return dict(zip(categories, map(float, probs)))
|
19 |
|
20 |
+
# %% ../app.ipynb 8
|
21 |
image = gr.Image(width=192, height=192)
|
22 |
label = gr.Label()
|
23 |
+
examples = ['images/grizzly.jpg', 'images/black.jpg', 'images/teddy.jpg',
|
24 |
+
'images/text.png', 'images/einstein.png', 'images/dunno.jpg']
|
25 |
|
26 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
27 |
intf.launch(inline=False)
|
app_ipywidgets.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
images/einstein.png
ADDED
images/text.png
ADDED
requirements.txt
CHANGED
@@ -1 +1,2 @@
|
|
1 |
-
fastai
|
|
|
|
1 |
+
fastai
|
2 |
+
gradio
|