Spaces:
Sleeping
Sleeping
Aaron Collins
commited on
Commit
·
b9de62c
1
Parent(s):
95e8813
gradio update, image render fix
Browse files- .ipynb_checkpoints/gradio_template-checkpoint.ipynb +0 -0
- app.py +3 -3
- gradio_template.ipynb +5 -198
.ipynb_checkpoints/gradio_template-checkpoint.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
app.py
CHANGED
@@ -13,15 +13,15 @@ import gradio as gr
|
|
13 |
learn = load_learner('model.pkl')
|
14 |
|
15 |
|
16 |
-
# %% gradio_template.ipynb
|
17 |
categories = ('joyful', 'neutral', 'sad')
|
18 |
|
19 |
def classify_image(img):
|
20 |
pred,idx,probs = learn.predict(img)
|
21 |
return dict(zip(categories, map(float, probs)))
|
22 |
|
23 |
-
# %% gradio_template.ipynb
|
24 |
-
image = gr.Image(
|
25 |
label = gr.Label()
|
26 |
examples = ['joyful_face.jpg', 'neutral_face.jpg', 'sad_face.jpg']
|
27 |
|
|
|
13 |
learn = load_learner('model.pkl')
|
14 |
|
15 |
|
16 |
+
# %% gradio_template.ipynb 5
|
17 |
categories = ('joyful', 'neutral', 'sad')
|
18 |
|
19 |
def classify_image(img):
|
20 |
pred,idx,probs = learn.predict(img)
|
21 |
return dict(zip(categories, map(float, probs)))
|
22 |
|
23 |
+
# %% gradio_template.ipynb 7
|
24 |
+
image = gr.Image(image_mode='RGB')
|
25 |
label = gr.Label()
|
26 |
examples = ['joyful_face.jpg', 'neutral_face.jpg', 'sad_face.jpg']
|
27 |
|
gradio_template.ipynb
CHANGED
@@ -193,7 +193,7 @@
|
|
193 |
},
|
194 |
{
|
195 |
"cell_type": "code",
|
196 |
-
"execution_count":
|
197 |
"id": "3d056050-537d-4a98-8a2a-7194e8969ca0",
|
198 |
"metadata": {},
|
199 |
"outputs": [
|
@@ -201,7 +201,7 @@
|
|
201 |
"name": "stdout",
|
202 |
"output_type": "stream",
|
203 |
"text": [
|
204 |
-
"Running on local URL: http://127.0.0.1:7861\n",
|
205 |
"\n",
|
206 |
"To create a public link, set `share=True` in `launch()`.\n"
|
207 |
]
|
@@ -210,207 +210,14 @@
|
|
210 |
"data": {
|
211 |
"text/plain": []
|
212 |
},
|
213 |
-
"execution_count":
|
214 |
"metadata": {},
|
215 |
"output_type": "execute_result"
|
216 |
-
},
|
217 |
-
{
|
218 |
-
"name": "stdout",
|
219 |
-
"output_type": "stream",
|
220 |
-
"text": [
|
221 |
-
"IMPORTANT: You are using gradio version 3.41.2, however version 4.44.1 is available, please upgrade.\n",
|
222 |
-
"--------\n"
|
223 |
-
]
|
224 |
-
},
|
225 |
-
{
|
226 |
-
"data": {
|
227 |
-
"text/html": [
|
228 |
-
"\n",
|
229 |
-
"<style>\n",
|
230 |
-
" /* Turns off some styling */\n",
|
231 |
-
" progress {\n",
|
232 |
-
" /* gets rid of default border in Firefox and Opera. */\n",
|
233 |
-
" border: none;\n",
|
234 |
-
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
235 |
-
" background-size: auto;\n",
|
236 |
-
" }\n",
|
237 |
-
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
238 |
-
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
239 |
-
" }\n",
|
240 |
-
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
241 |
-
" background: #F44336;\n",
|
242 |
-
" }\n",
|
243 |
-
"</style>\n"
|
244 |
-
],
|
245 |
-
"text/plain": [
|
246 |
-
"<IPython.core.display.HTML object>"
|
247 |
-
]
|
248 |
-
},
|
249 |
-
"metadata": {},
|
250 |
-
"output_type": "display_data"
|
251 |
-
},
|
252 |
-
{
|
253 |
-
"data": {
|
254 |
-
"text/html": [],
|
255 |
-
"text/plain": [
|
256 |
-
"<IPython.core.display.HTML object>"
|
257 |
-
]
|
258 |
-
},
|
259 |
-
"metadata": {},
|
260 |
-
"output_type": "display_data"
|
261 |
-
},
|
262 |
-
{
|
263 |
-
"data": {
|
264 |
-
"text/html": [
|
265 |
-
"\n",
|
266 |
-
"<style>\n",
|
267 |
-
" /* Turns off some styling */\n",
|
268 |
-
" progress {\n",
|
269 |
-
" /* gets rid of default border in Firefox and Opera. */\n",
|
270 |
-
" border: none;\n",
|
271 |
-
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
272 |
-
" background-size: auto;\n",
|
273 |
-
" }\n",
|
274 |
-
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
275 |
-
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
276 |
-
" }\n",
|
277 |
-
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
278 |
-
" background: #F44336;\n",
|
279 |
-
" }\n",
|
280 |
-
"</style>\n"
|
281 |
-
],
|
282 |
-
"text/plain": [
|
283 |
-
"<IPython.core.display.HTML object>"
|
284 |
-
]
|
285 |
-
},
|
286 |
-
"metadata": {},
|
287 |
-
"output_type": "display_data"
|
288 |
-
},
|
289 |
-
{
|
290 |
-
"data": {
|
291 |
-
"text/html": [],
|
292 |
-
"text/plain": [
|
293 |
-
"<IPython.core.display.HTML object>"
|
294 |
-
]
|
295 |
-
},
|
296 |
-
"metadata": {},
|
297 |
-
"output_type": "display_data"
|
298 |
-
},
|
299 |
-
{
|
300 |
-
"data": {
|
301 |
-
"text/html": [
|
302 |
-
"\n",
|
303 |
-
"<style>\n",
|
304 |
-
" /* Turns off some styling */\n",
|
305 |
-
" progress {\n",
|
306 |
-
" /* gets rid of default border in Firefox and Opera. */\n",
|
307 |
-
" border: none;\n",
|
308 |
-
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
309 |
-
" background-size: auto;\n",
|
310 |
-
" }\n",
|
311 |
-
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
312 |
-
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
313 |
-
" }\n",
|
314 |
-
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
315 |
-
" background: #F44336;\n",
|
316 |
-
" }\n",
|
317 |
-
"</style>\n"
|
318 |
-
],
|
319 |
-
"text/plain": [
|
320 |
-
"<IPython.core.display.HTML object>"
|
321 |
-
]
|
322 |
-
},
|
323 |
-
"metadata": {},
|
324 |
-
"output_type": "display_data"
|
325 |
-
},
|
326 |
-
{
|
327 |
-
"data": {
|
328 |
-
"text/html": [],
|
329 |
-
"text/plain": [
|
330 |
-
"<IPython.core.display.HTML object>"
|
331 |
-
]
|
332 |
-
},
|
333 |
-
"metadata": {},
|
334 |
-
"output_type": "display_data"
|
335 |
-
},
|
336 |
-
{
|
337 |
-
"data": {
|
338 |
-
"text/html": [
|
339 |
-
"\n",
|
340 |
-
"<style>\n",
|
341 |
-
" /* Turns off some styling */\n",
|
342 |
-
" progress {\n",
|
343 |
-
" /* gets rid of default border in Firefox and Opera. */\n",
|
344 |
-
" border: none;\n",
|
345 |
-
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
346 |
-
" background-size: auto;\n",
|
347 |
-
" }\n",
|
348 |
-
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
349 |
-
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
350 |
-
" }\n",
|
351 |
-
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
352 |
-
" background: #F44336;\n",
|
353 |
-
" }\n",
|
354 |
-
"</style>\n"
|
355 |
-
],
|
356 |
-
"text/plain": [
|
357 |
-
"<IPython.core.display.HTML object>"
|
358 |
-
]
|
359 |
-
},
|
360 |
-
"metadata": {},
|
361 |
-
"output_type": "display_data"
|
362 |
-
},
|
363 |
-
{
|
364 |
-
"data": {
|
365 |
-
"text/html": [],
|
366 |
-
"text/plain": [
|
367 |
-
"<IPython.core.display.HTML object>"
|
368 |
-
]
|
369 |
-
},
|
370 |
-
"metadata": {},
|
371 |
-
"output_type": "display_data"
|
372 |
-
},
|
373 |
-
{
|
374 |
-
"data": {
|
375 |
-
"text/html": [
|
376 |
-
"\n",
|
377 |
-
"<style>\n",
|
378 |
-
" /* Turns off some styling */\n",
|
379 |
-
" progress {\n",
|
380 |
-
" /* gets rid of default border in Firefox and Opera. */\n",
|
381 |
-
" border: none;\n",
|
382 |
-
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
383 |
-
" background-size: auto;\n",
|
384 |
-
" }\n",
|
385 |
-
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
386 |
-
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
387 |
-
" }\n",
|
388 |
-
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
389 |
-
" background: #F44336;\n",
|
390 |
-
" }\n",
|
391 |
-
"</style>\n"
|
392 |
-
],
|
393 |
-
"text/plain": [
|
394 |
-
"<IPython.core.display.HTML object>"
|
395 |
-
]
|
396 |
-
},
|
397 |
-
"metadata": {},
|
398 |
-
"output_type": "display_data"
|
399 |
-
},
|
400 |
-
{
|
401 |
-
"data": {
|
402 |
-
"text/html": [],
|
403 |
-
"text/plain": [
|
404 |
-
"<IPython.core.display.HTML object>"
|
405 |
-
]
|
406 |
-
},
|
407 |
-
"metadata": {},
|
408 |
-
"output_type": "display_data"
|
409 |
}
|
410 |
],
|
411 |
"source": [
|
412 |
" #|export\n",
|
413 |
-
"image = gr.Image(
|
414 |
"label = gr.Label()\n",
|
415 |
"examples = ['joyful_face.jpg', 'neutral_face.jpg', 'sad_face.jpg']\n",
|
416 |
"\n",
|
@@ -420,7 +227,7 @@
|
|
420 |
},
|
421 |
{
|
422 |
"cell_type": "code",
|
423 |
-
"execution_count":
|
424 |
"id": "33881775-f182-4bff-b6a1-bca02c68c4eb",
|
425 |
"metadata": {},
|
426 |
"outputs": [],
|
|
|
193 |
},
|
194 |
{
|
195 |
"cell_type": "code",
|
196 |
+
"execution_count": 10,
|
197 |
"id": "3d056050-537d-4a98-8a2a-7194e8969ca0",
|
198 |
"metadata": {},
|
199 |
"outputs": [
|
|
|
201 |
"name": "stdout",
|
202 |
"output_type": "stream",
|
203 |
"text": [
|
204 |
+
"* Running on local URL: http://127.0.0.1:7861\n",
|
205 |
"\n",
|
206 |
"To create a public link, set `share=True` in `launch()`.\n"
|
207 |
]
|
|
|
210 |
"data": {
|
211 |
"text/plain": []
|
212 |
},
|
213 |
+
"execution_count": 10,
|
214 |
"metadata": {},
|
215 |
"output_type": "execute_result"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
}
|
217 |
],
|
218 |
"source": [
|
219 |
" #|export\n",
|
220 |
+
"image = gr.Image(image_mode='RGB')\n",
|
221 |
"label = gr.Label()\n",
|
222 |
"examples = ['joyful_face.jpg', 'neutral_face.jpg', 'sad_face.jpg']\n",
|
223 |
"\n",
|
|
|
227 |
},
|
228 |
{
|
229 |
"cell_type": "code",
|
230 |
+
"execution_count": 11,
|
231 |
"id": "33881775-f182-4bff-b6a1-bca02c68c4eb",
|
232 |
"metadata": {},
|
233 |
"outputs": [],
|