njc-ai commited on
Commit
d8748f0
1 Parent(s): d16e3d9

update app model

Browse files
Files changed (2) hide show
  1. app.ipynb +11 -160
  2. app.py +2 -2
app.ipynb CHANGED
@@ -75,7 +75,7 @@
75
  },
76
  {
77
  "cell_type": "code",
78
- "execution_count": 68,
79
  "metadata": {},
80
  "outputs": [
81
  {
@@ -125,7 +125,7 @@
125
  " 2.7985e-07, 8.2198e-09]))"
126
  ]
127
  },
128
- "execution_count": 68,
129
  "metadata": {},
130
  "output_type": "execute_result"
131
  }
@@ -136,12 +136,12 @@
136
  },
137
  {
138
  "cell_type": "code",
139
- "execution_count": 69,
140
  "metadata": {},
141
  "outputs": [],
142
  "source": [
143
  "#|export\n",
144
- "categories = ('Jacaranda', 'Bougainvillea', 'Clavalina tree', 'Birds of paradise plant oaxaca', 'Flame vine', 'Plumeria rubra', 'Ceiba speciosa', 'Poinsettia tree', 'Calistemo', 'Flamboyan', 'Mexican creeper','primavera rosa')\n",
145
  "\n",
146
  "def classify_image(img):\n",
147
  " pred,idx,probs = learn.predict(img)\n",
@@ -193,7 +193,7 @@
193
  },
194
  {
195
  "cell_type": "code",
196
- "execution_count": 71,
197
  "metadata": {},
198
  "outputs": [
199
  {
@@ -229,13 +229,12 @@
229
  "\n",
230
  "# Print the sorted list of photos\n",
231
  "print(photos)\n",
232
- "\n",
233
- "example_photo=['Poinsettia tree.jpg', 'Mexican creeper.jpg', 'Plumeria rubra.jpg']\n"
234
  ]
235
  },
236
  {
237
  "cell_type": "code",
238
- "execution_count": 75,
239
  "metadata": {},
240
  "outputs": [
241
  {
@@ -258,55 +257,18 @@
258
  "text": [
259
  "IMPORTANT: You are using gradio version 3.9, however version 3.14.0 is available, please upgrade.\n",
260
  "--------\n",
261
- "Running on local URL: http://127.0.0.1:7875\n",
262
  "\n",
263
  "To create a public link, set `share=True` in `launch()`.\n"
264
  ]
265
  },
266
- {
267
- "data": {
268
- "text/html": [
269
- "\n",
270
- "<style>\n",
271
- " /* Turns off some styling */\n",
272
- " progress {\n",
273
- " /* gets rid of default border in Firefox and Opera. */\n",
274
- " border: none;\n",
275
- " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
276
- " background-size: auto;\n",
277
- " }\n",
278
- " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
279
- " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
280
- " }\n",
281
- " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
282
- " background: #F44336;\n",
283
- " }\n",
284
- "</style>\n"
285
- ],
286
- "text/plain": [
287
- "<IPython.core.display.HTML object>"
288
- ]
289
- },
290
- "metadata": {},
291
- "output_type": "display_data"
292
- },
293
- {
294
- "data": {
295
- "text/html": [],
296
- "text/plain": [
297
- "<IPython.core.display.HTML object>"
298
- ]
299
- },
300
- "metadata": {},
301
- "output_type": "display_data"
302
- },
303
  {
304
  "data": {
305
  "text/plain": [
306
- "(<gradio.routes.App at 0x2a41a6110>, 'http://127.0.0.1:7875/', None)"
307
  ]
308
  },
309
- "execution_count": 75,
310
  "metadata": {},
311
  "output_type": "execute_result"
312
  },
@@ -411,117 +373,6 @@
411
  "metadata": {},
412
  "output_type": "display_data"
413
  },
414
- {
415
- "data": {
416
- "text/html": [],
417
- "text/plain": [
418
- "<IPython.core.display.HTML object>"
419
- ]
420
- },
421
- "metadata": {},
422
- "output_type": "display_data"
423
- },
424
- {
425
- "data": {
426
- "text/html": [
427
- "\n",
428
- "<style>\n",
429
- " /* Turns off some styling */\n",
430
- " progress {\n",
431
- " /* gets rid of default border in Firefox and Opera. */\n",
432
- " border: none;\n",
433
- " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
434
- " background-size: auto;\n",
435
- " }\n",
436
- " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
437
- " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
438
- " }\n",
439
- " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
440
- " background: #F44336;\n",
441
- " }\n",
442
- "</style>\n"
443
- ],
444
- "text/plain": [
445
- "<IPython.core.display.HTML object>"
446
- ]
447
- },
448
- "metadata": {},
449
- "output_type": "display_data"
450
- },
451
- {
452
- "data": {
453
- "text/html": [],
454
- "text/plain": [
455
- "<IPython.core.display.HTML object>"
456
- ]
457
- },
458
- "metadata": {},
459
- "output_type": "display_data"
460
- },
461
- {
462
- "data": {
463
- "text/html": [
464
- "\n",
465
- "<style>\n",
466
- " /* Turns off some styling */\n",
467
- " progress {\n",
468
- " /* gets rid of default border in Firefox and Opera. */\n",
469
- " border: none;\n",
470
- " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
471
- " background-size: auto;\n",
472
- " }\n",
473
- " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
474
- " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
475
- " }\n",
476
- " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
477
- " background: #F44336;\n",
478
- " }\n",
479
- "</style>\n"
480
- ],
481
- "text/plain": [
482
- "<IPython.core.display.HTML object>"
483
- ]
484
- },
485
- "metadata": {},
486
- "output_type": "display_data"
487
- },
488
- {
489
- "data": {
490
- "text/html": [],
491
- "text/plain": [
492
- "<IPython.core.display.HTML object>"
493
- ]
494
- },
495
- "metadata": {},
496
- "output_type": "display_data"
497
- },
498
- {
499
- "data": {
500
- "text/html": [
501
- "\n",
502
- "<style>\n",
503
- " /* Turns off some styling */\n",
504
- " progress {\n",
505
- " /* gets rid of default border in Firefox and Opera. */\n",
506
- " border: none;\n",
507
- " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
508
- " background-size: auto;\n",
509
- " }\n",
510
- " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
511
- " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
512
- " }\n",
513
- " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
514
- " background: #F44336;\n",
515
- " }\n",
516
- "</style>\n"
517
- ],
518
- "text/plain": [
519
- "<IPython.core.display.HTML object>"
520
- ]
521
- },
522
- "metadata": {},
523
- "output_type": "display_data"
524
- },
525
  {
526
  "data": {
527
  "text/html": [],
@@ -539,7 +390,7 @@
539
  "label = gr.outputs.Label()\n",
540
  "examples = photos\n",
541
  "\n",
542
- "intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=example_photo)\n",
543
  "intf.launch(inline=False)"
544
  ]
545
  }
 
75
  },
76
  {
77
  "cell_type": "code",
78
+ "execution_count": 77,
79
  "metadata": {},
80
  "outputs": [
81
  {
 
125
  " 2.7985e-07, 8.2198e-09]))"
126
  ]
127
  },
128
+ "execution_count": 77,
129
  "metadata": {},
130
  "output_type": "execute_result"
131
  }
 
136
  },
137
  {
138
  "cell_type": "code",
139
+ "execution_count": 79,
140
  "metadata": {},
141
  "outputs": [],
142
  "source": [
143
  "#|export\n",
144
+ "categories = learn.dls.vocab\n",
145
  "\n",
146
  "def classify_image(img):\n",
147
  " pred,idx,probs = learn.predict(img)\n",
 
193
  },
194
  {
195
  "cell_type": "code",
196
+ "execution_count": 82,
197
  "metadata": {},
198
  "outputs": [
199
  {
 
229
  "\n",
230
  "# Print the sorted list of photos\n",
231
  "print(photos)\n",
232
+ "\n"
 
233
  ]
234
  },
235
  {
236
  "cell_type": "code",
237
+ "execution_count": 81,
238
  "metadata": {},
239
  "outputs": [
240
  {
 
257
  "text": [
258
  "IMPORTANT: You are using gradio version 3.9, however version 3.14.0 is available, please upgrade.\n",
259
  "--------\n",
260
+ "Running on local URL: http://127.0.0.1:7876\n",
261
  "\n",
262
  "To create a public link, set `share=True` in `launch()`.\n"
263
  ]
264
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  {
266
  "data": {
267
  "text/plain": [
268
+ "(<gradio.routes.App at 0x2a41d6d40>, 'http://127.0.0.1:7876/', None)"
269
  ]
270
  },
271
+ "execution_count": 81,
272
  "metadata": {},
273
  "output_type": "execute_result"
274
  },
 
373
  "metadata": {},
374
  "output_type": "display_data"
375
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376
  {
377
  "data": {
378
  "text/html": [],
 
390
  "label = gr.outputs.Label()\n",
391
  "examples = photos\n",
392
  "\n",
393
+ "intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
394
  "intf.launch(inline=False)"
395
  ]
396
  }
app.py CHANGED
@@ -9,7 +9,7 @@ learn = load_learner('mexicanPlants (1).pkl')
9
 
10
 
11
  #|export
12
- categories = ('Jacaranda', 'Bougainvillea', 'Clavalina tree', 'Birds of paradise plant oaxaca', 'Flame vine', 'Plumeria rubra', 'Ceiba speciosa', 'Poinsettia tree', 'Calistemo', 'Flamboyan', 'Mexican creeper','primavera rosa')
13
 
14
  def classify_image(img):
15
  pred,idx,probs = learn.predict(img)
@@ -31,7 +31,7 @@ photos = []
31
  for file in all_files:
32
  # Check if the file is a photo
33
  if file.endswith(('.jpg', '.jpeg', '.png', '.bmp', '.gif')):
34
- # If it is, add it to the list of photos
35
  photos.append(file)
36
 
37
  image = gr.inputs.Image(shape=(192,192))
 
9
 
10
 
11
  #|export
12
+ categories = learn.dls.vocab
13
 
14
  def classify_image(img):
15
  pred,idx,probs = learn.predict(img)
 
31
  for file in all_files:
32
  # Check if the file is a photo
33
  if file.endswith(('.jpg', '.jpeg', '.png', '.bmp', '.gif')):
34
+ # If it is, add it to the list of photosgi
35
  photos.append(file)
36
 
37
  image = gr.inputs.Image(shape=(192,192))