changed name
Browse files
app.ipynb
DELETED
@@ -1,370 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"cells": [
|
3 |
-
{
|
4 |
-
"cell_type": "code",
|
5 |
-
"execution_count": 1,
|
6 |
-
"metadata": {},
|
7 |
-
"outputs": [],
|
8 |
-
"source": [
|
9 |
-
"#/default_exp app"
|
10 |
-
]
|
11 |
-
},
|
12 |
-
{
|
13 |
-
"cell_type": "code",
|
14 |
-
"execution_count": 2,
|
15 |
-
"metadata": {},
|
16 |
-
"outputs": [],
|
17 |
-
"source": [
|
18 |
-
"#/export\n",
|
19 |
-
"from fastai.vision.all import *\n",
|
20 |
-
"import gradio as gr\n",
|
21 |
-
"\n",
|
22 |
-
"def is_cat(x): return x[0].isupper()"
|
23 |
-
]
|
24 |
-
},
|
25 |
-
{
|
26 |
-
"cell_type": "code",
|
27 |
-
"execution_count": 3,
|
28 |
-
"metadata": {},
|
29 |
-
"outputs": [],
|
30 |
-
"source": [
|
31 |
-
"#/export\n",
|
32 |
-
"learn = load_learner('model.pkl')"
|
33 |
-
]
|
34 |
-
},
|
35 |
-
{
|
36 |
-
"cell_type": "code",
|
37 |
-
"execution_count": 4,
|
38 |
-
"metadata": {},
|
39 |
-
"outputs": [],
|
40 |
-
"source": [
|
41 |
-
"#/export\n",
|
42 |
-
"categories = ('Dog','Cat')\n",
|
43 |
-
"\n",
|
44 |
-
"def classify_image(img):\n",
|
45 |
-
" pred,idx,probs = learn.predict(img)\n",
|
46 |
-
" return dict(zip(categories,map(float,probs)))"
|
47 |
-
]
|
48 |
-
},
|
49 |
-
{
|
50 |
-
"cell_type": "code",
|
51 |
-
"execution_count": 5,
|
52 |
-
"metadata": {},
|
53 |
-
"outputs": [
|
54 |
-
{
|
55 |
-
"data": {
|
56 |
-
"text/html": [
|
57 |
-
"\n",
|
58 |
-
"<style>\n",
|
59 |
-
" /* Turns off some styling */\n",
|
60 |
-
" progress {\n",
|
61 |
-
" /* gets rid of default border in Firefox and Opera. */\n",
|
62 |
-
" border: none;\n",
|
63 |
-
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
64 |
-
" background-size: auto;\n",
|
65 |
-
" }\n",
|
66 |
-
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
67 |
-
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
68 |
-
" }\n",
|
69 |
-
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
70 |
-
" background: #F44336;\n",
|
71 |
-
" }\n",
|
72 |
-
"</style>\n"
|
73 |
-
],
|
74 |
-
"text/plain": [
|
75 |
-
"<IPython.core.display.HTML object>"
|
76 |
-
]
|
77 |
-
},
|
78 |
-
"metadata": {},
|
79 |
-
"output_type": "display_data"
|
80 |
-
},
|
81 |
-
{
|
82 |
-
"data": {
|
83 |
-
"text/html": [],
|
84 |
-
"text/plain": [
|
85 |
-
"<IPython.core.display.HTML object>"
|
86 |
-
]
|
87 |
-
},
|
88 |
-
"metadata": {},
|
89 |
-
"output_type": "display_data"
|
90 |
-
},
|
91 |
-
{
|
92 |
-
"data": {
|
93 |
-
"text/plain": [
|
94 |
-
"{'Dog': 0.9999974966049194, 'Cat': 2.5427661967114545e-06}"
|
95 |
-
]
|
96 |
-
},
|
97 |
-
"execution_count": 5,
|
98 |
-
"metadata": {},
|
99 |
-
"output_type": "execute_result"
|
100 |
-
}
|
101 |
-
],
|
102 |
-
"source": [
|
103 |
-
"classify_image('dog.jpeg')"
|
104 |
-
]
|
105 |
-
},
|
106 |
-
{
|
107 |
-
"cell_type": "code",
|
108 |
-
"execution_count": null,
|
109 |
-
"metadata": {},
|
110 |
-
"outputs": [
|
111 |
-
{
|
112 |
-
"name": "stderr",
|
113 |
-
"output_type": "stream",
|
114 |
-
"text": [
|
115 |
-
"/Users/katetran/mambaforge/lib/python3.10/site-packages/gradio/inputs.py:256: UserWarning: Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components\n",
|
116 |
-
" warnings.warn(\n",
|
117 |
-
"/Users/katetran/mambaforge/lib/python3.10/site-packages/gradio/deprecation.py:40: UserWarning: `optional` parameter is deprecated, and it has no effect\n",
|
118 |
-
" warnings.warn(value)\n",
|
119 |
-
"/Users/katetran/mambaforge/lib/python3.10/site-packages/gradio/outputs.py:196: UserWarning: Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components\n",
|
120 |
-
" warnings.warn(\n",
|
121 |
-
"/Users/katetran/mambaforge/lib/python3.10/site-packages/gradio/deprecation.py:40: UserWarning: The 'type' parameter has been deprecated. Use the Number component instead.\n",
|
122 |
-
" warnings.warn(value)\n"
|
123 |
-
]
|
124 |
-
},
|
125 |
-
{
|
126 |
-
"name": "stdout",
|
127 |
-
"output_type": "stream",
|
128 |
-
"text": [
|
129 |
-
"Running on local URL: http://127.0.0.1:7860\n",
|
130 |
-
"\n",
|
131 |
-
"To create a public link, set `share=True` in `launch()`.\n"
|
132 |
-
]
|
133 |
-
},
|
134 |
-
{
|
135 |
-
"data": {
|
136 |
-
"text/plain": [
|
137 |
-
"(<gradio.routes.App at 0x1795c7e50>, 'http://127.0.0.1:7860/', None)"
|
138 |
-
]
|
139 |
-
},
|
140 |
-
"execution_count": 6,
|
141 |
-
"metadata": {},
|
142 |
-
"output_type": "execute_result"
|
143 |
-
},
|
144 |
-
{
|
145 |
-
"data": {
|
146 |
-
"text/html": [
|
147 |
-
"\n",
|
148 |
-
"<style>\n",
|
149 |
-
" /* Turns off some styling */\n",
|
150 |
-
" progress {\n",
|
151 |
-
" /* gets rid of default border in Firefox and Opera. */\n",
|
152 |
-
" border: none;\n",
|
153 |
-
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
154 |
-
" background-size: auto;\n",
|
155 |
-
" }\n",
|
156 |
-
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
157 |
-
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
158 |
-
" }\n",
|
159 |
-
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
160 |
-
" background: #F44336;\n",
|
161 |
-
" }\n",
|
162 |
-
"</style>\n"
|
163 |
-
],
|
164 |
-
"text/plain": [
|
165 |
-
"<IPython.core.display.HTML object>"
|
166 |
-
]
|
167 |
-
},
|
168 |
-
"metadata": {},
|
169 |
-
"output_type": "display_data"
|
170 |
-
},
|
171 |
-
{
|
172 |
-
"data": {
|
173 |
-
"text/html": [],
|
174 |
-
"text/plain": [
|
175 |
-
"<IPython.core.display.HTML object>"
|
176 |
-
]
|
177 |
-
},
|
178 |
-
"metadata": {},
|
179 |
-
"output_type": "display_data"
|
180 |
-
},
|
181 |
-
{
|
182 |
-
"data": {
|
183 |
-
"text/html": [
|
184 |
-
"\n",
|
185 |
-
"<style>\n",
|
186 |
-
" /* Turns off some styling */\n",
|
187 |
-
" progress {\n",
|
188 |
-
" /* gets rid of default border in Firefox and Opera. */\n",
|
189 |
-
" border: none;\n",
|
190 |
-
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
191 |
-
" background-size: auto;\n",
|
192 |
-
" }\n",
|
193 |
-
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
194 |
-
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
195 |
-
" }\n",
|
196 |
-
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
197 |
-
" background: #F44336;\n",
|
198 |
-
" }\n",
|
199 |
-
"</style>\n"
|
200 |
-
],
|
201 |
-
"text/plain": [
|
202 |
-
"<IPython.core.display.HTML object>"
|
203 |
-
]
|
204 |
-
},
|
205 |
-
"metadata": {},
|
206 |
-
"output_type": "display_data"
|
207 |
-
},
|
208 |
-
{
|
209 |
-
"data": {
|
210 |
-
"text/html": [],
|
211 |
-
"text/plain": [
|
212 |
-
"<IPython.core.display.HTML object>"
|
213 |
-
]
|
214 |
-
},
|
215 |
-
"metadata": {},
|
216 |
-
"output_type": "display_data"
|
217 |
-
},
|
218 |
-
{
|
219 |
-
"data": {
|
220 |
-
"text/html": [
|
221 |
-
"\n",
|
222 |
-
"<style>\n",
|
223 |
-
" /* Turns off some styling */\n",
|
224 |
-
" progress {\n",
|
225 |
-
" /* gets rid of default border in Firefox and Opera. */\n",
|
226 |
-
" border: none;\n",
|
227 |
-
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
228 |
-
" background-size: auto;\n",
|
229 |
-
" }\n",
|
230 |
-
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
231 |
-
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
232 |
-
" }\n",
|
233 |
-
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
234 |
-
" background: #F44336;\n",
|
235 |
-
" }\n",
|
236 |
-
"</style>\n"
|
237 |
-
],
|
238 |
-
"text/plain": [
|
239 |
-
"<IPython.core.display.HTML object>"
|
240 |
-
]
|
241 |
-
},
|
242 |
-
"metadata": {},
|
243 |
-
"output_type": "display_data"
|
244 |
-
},
|
245 |
-
{
|
246 |
-
"data": {
|
247 |
-
"text/html": [],
|
248 |
-
"text/plain": [
|
249 |
-
"<IPython.core.display.HTML object>"
|
250 |
-
]
|
251 |
-
},
|
252 |
-
"metadata": {},
|
253 |
-
"output_type": "display_data"
|
254 |
-
},
|
255 |
-
{
|
256 |
-
"data": {
|
257 |
-
"text/html": [
|
258 |
-
"\n",
|
259 |
-
"<style>\n",
|
260 |
-
" /* Turns off some styling */\n",
|
261 |
-
" progress {\n",
|
262 |
-
" /* gets rid of default border in Firefox and Opera. */\n",
|
263 |
-
" border: none;\n",
|
264 |
-
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
265 |
-
" background-size: auto;\n",
|
266 |
-
" }\n",
|
267 |
-
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
268 |
-
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
269 |
-
" }\n",
|
270 |
-
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
271 |
-
" background: #F44336;\n",
|
272 |
-
" }\n",
|
273 |
-
"</style>\n"
|
274 |
-
],
|
275 |
-
"text/plain": [
|
276 |
-
"<IPython.core.display.HTML object>"
|
277 |
-
]
|
278 |
-
},
|
279 |
-
"metadata": {},
|
280 |
-
"output_type": "display_data"
|
281 |
-
},
|
282 |
-
{
|
283 |
-
"data": {
|
284 |
-
"text/html": [],
|
285 |
-
"text/plain": [
|
286 |
-
"<IPython.core.display.HTML object>"
|
287 |
-
]
|
288 |
-
},
|
289 |
-
"metadata": {},
|
290 |
-
"output_type": "display_data"
|
291 |
-
},
|
292 |
-
{
|
293 |
-
"data": {
|
294 |
-
"text/html": [
|
295 |
-
"\n",
|
296 |
-
"<style>\n",
|
297 |
-
" /* Turns off some styling */\n",
|
298 |
-
" progress {\n",
|
299 |
-
" /* gets rid of default border in Firefox and Opera. */\n",
|
300 |
-
" border: none;\n",
|
301 |
-
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
302 |
-
" background-size: auto;\n",
|
303 |
-
" }\n",
|
304 |
-
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
305 |
-
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
306 |
-
" }\n",
|
307 |
-
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
308 |
-
" background: #F44336;\n",
|
309 |
-
" }\n",
|
310 |
-
"</style>\n"
|
311 |
-
],
|
312 |
-
"text/plain": [
|
313 |
-
"<IPython.core.display.HTML object>"
|
314 |
-
]
|
315 |
-
},
|
316 |
-
"metadata": {},
|
317 |
-
"output_type": "display_data"
|
318 |
-
},
|
319 |
-
{
|
320 |
-
"data": {
|
321 |
-
"text/html": [],
|
322 |
-
"text/plain": [
|
323 |
-
"<IPython.core.display.HTML object>"
|
324 |
-
]
|
325 |
-
},
|
326 |
-
"metadata": {},
|
327 |
-
"output_type": "display_data"
|
328 |
-
}
|
329 |
-
],
|
330 |
-
"source": [
|
331 |
-
"#/export\n",
|
332 |
-
"image = gr.inputs.Image(shape=(192,192))\n",
|
333 |
-
"label = gr.outputs.Label()\n",
|
334 |
-
"title = \"Pet Breed Classifier\"\n",
|
335 |
-
"description = \"A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace spaces.\"\n",
|
336 |
-
"examples = ['dog.jpeg','cat.jpeg', 'dunno.jpeg']\n",
|
337 |
-
"\n",
|
338 |
-
"intf = gr.Interface(fn=classify_image, inputs=image, outputs=label,examples=examples)\n",
|
339 |
-
"intf.launch(inline=False)"
|
340 |
-
]
|
341 |
-
}
|
342 |
-
],
|
343 |
-
"metadata": {
|
344 |
-
"kernelspec": {
|
345 |
-
"display_name": "Python 3.10.6 ('base')",
|
346 |
-
"language": "python",
|
347 |
-
"name": "python3"
|
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.10.6"
|
360 |
-
},
|
361 |
-
"orig_nbformat": 4,
|
362 |
-
"vscode": {
|
363 |
-
"interpreter": {
|
364 |
-
"hash": "de7cb0b1218c3fc8713775238ab21314d73326b1c691e0df13913a336de394b8"
|
365 |
-
}
|
366 |
-
}
|
367 |
-
},
|
368 |
-
"nbformat": 4,
|
369 |
-
"nbformat_minor": 2
|
370 |
-
}
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
@@ -26,7 +26,7 @@ image = gr.inputs.Image(shape=(192,192))
|
|
26 |
label = gr.outputs.Label()
|
27 |
title = "Pet Breed Classifier"
|
28 |
description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace spaces."
|
29 |
-
examples = ['dog.jpeg','cat.jpeg'
|
30 |
|
31 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label,examples=examples)
|
32 |
intf.launch(inline=False)
|
|
|
26 |
label = gr.outputs.Label()
|
27 |
title = "Pet Breed Classifier"
|
28 |
description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace spaces."
|
29 |
+
examples = ['dog.jpeg','cat.jpeg']
|
30 |
|
31 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label,examples=examples)
|
32 |
intf.launch(inline=False)
|