Spaces:
Sleeping
Sleeping
Aspiring Astro
commited on
Commit
•
6426419
1
Parent(s):
4099db1
fix loss and matrix event, remove examples
Browse files
app.ipynb
CHANGED
@@ -447,7 +447,7 @@
|
|
447 |
},
|
448 |
{
|
449 |
"cell_type": "code",
|
450 |
-
"execution_count":
|
451 |
"id": "a48e7483-c04b-4048-a1ae-34a8c7986a57",
|
452 |
"metadata": {},
|
453 |
"outputs": [
|
@@ -496,18 +496,27 @@
|
|
496 |
},
|
497 |
"metadata": {},
|
498 |
"output_type": "display_data"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
499 |
}
|
500 |
],
|
501 |
"source": [
|
502 |
"#| export\n",
|
503 |
"example_images = [ 'cheetah.jpg', 'jaguar.jpg', 'tiger.jpg', 'cougar.jpg', 'lion.jpg', 'african leopard.jpg', 'clouded leopard.jpg', 'snow leopard.jpg', 'hidden.png', 'hidden2.png' ]\n",
|
504 |
"\n",
|
505 |
-
"model_matrix = [ 'models/resnet101-confusion-matrix.png', 'models/resnet18-confusion-matrix.png', 'models/resnet50-confusion-matrix.png',\n",
|
506 |
-
"'models/resnet152-confusion-matrix.png', 'models/resnet34-confusion-matrix.png' ]\n",
|
507 |
-
"\n",
|
508 |
-
"model_losses = [ 'models/resnet101-top-losses.png', 'models/resnet18-top-losses.png', 'models/resnet50-top-losses.png',\n",
|
509 |
-
"'models/resnet152-top-losses.png', 'models/resnet34-top-losses.png' ]\n",
|
510 |
-
"\n",
|
511 |
"demo = gr.Blocks()\n",
|
512 |
"with demo:\n",
|
513 |
" with gr.Column(variant=\"panel\"):\n",
|
@@ -521,13 +530,13 @@
|
|
521 |
" losses=gr.outputs.Image(type='filepath', label=\"Top Losses\")\n",
|
522 |
" result = gr.outputs.Label(label=\"Result\")\n",
|
523 |
" \n",
|
524 |
-
" model.change(fn=select_model, inputs=model, outputs=selected)\n",
|
525 |
" btnClassify.click(fn=classify_image, inputs=image, outputs=result)\n",
|
526 |
" img_gallery = gr.Examples(examples=example_images, inputs=image)\n",
|
527 |
-
"
|
528 |
-
"
|
529 |
-
"
|
530 |
-
"
|
|
|
531 |
"\n",
|
532 |
"demo.launch(debug=True, inline=False)\n",
|
533 |
" # intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=example_images, title=title, description=description )\n",
|
@@ -537,15 +546,31 @@
|
|
537 |
},
|
538 |
{
|
539 |
"cell_type": "code",
|
540 |
-
"execution_count":
|
541 |
"id": "cab071f9-7c3b-4b35-a0d1-3687731ffce5",
|
542 |
"metadata": {},
|
543 |
-
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
544 |
"source": [
|
545 |
"import nbdev\n",
|
546 |
"nbdev.export.nb_export('app.ipynb', './')\n",
|
547 |
"print('Export successful')"
|
548 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
549 |
}
|
550 |
],
|
551 |
"metadata": {
|
|
|
447 |
},
|
448 |
{
|
449 |
"cell_type": "code",
|
450 |
+
"execution_count": 6,
|
451 |
"id": "a48e7483-c04b-4048-a1ae-34a8c7986a57",
|
452 |
"metadata": {},
|
453 |
"outputs": [
|
|
|
496 |
},
|
497 |
"metadata": {},
|
498 |
"output_type": "display_data"
|
499 |
+
},
|
500 |
+
{
|
501 |
+
"name": "stdout",
|
502 |
+
"output_type": "stream",
|
503 |
+
"text": [
|
504 |
+
"Keyboard interruption in main thread... closing server.\n"
|
505 |
+
]
|
506 |
+
},
|
507 |
+
{
|
508 |
+
"data": {
|
509 |
+
"text/plain": []
|
510 |
+
},
|
511 |
+
"execution_count": 6,
|
512 |
+
"metadata": {},
|
513 |
+
"output_type": "execute_result"
|
514 |
}
|
515 |
],
|
516 |
"source": [
|
517 |
"#| export\n",
|
518 |
"example_images = [ 'cheetah.jpg', 'jaguar.jpg', 'tiger.jpg', 'cougar.jpg', 'lion.jpg', 'african leopard.jpg', 'clouded leopard.jpg', 'snow leopard.jpg', 'hidden.png', 'hidden2.png' ]\n",
|
519 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
520 |
"demo = gr.Blocks()\n",
|
521 |
"with demo:\n",
|
522 |
" with gr.Column(variant=\"panel\"):\n",
|
|
|
530 |
" losses=gr.outputs.Image(type='filepath', label=\"Top Losses\")\n",
|
531 |
" result = gr.outputs.Label(label=\"Result\")\n",
|
532 |
" \n",
|
|
|
533 |
" btnClassify.click(fn=classify_image, inputs=image, outputs=result)\n",
|
534 |
" img_gallery = gr.Examples(examples=example_images, inputs=image)\n",
|
535 |
+
"\n",
|
536 |
+
" # Register all ev\n",
|
537 |
+
" model.change(fn=select_model, inputs=model, outputs=selected)\n",
|
538 |
+
" model.change(fn=update_matrix, outputs=matrix)\n",
|
539 |
+
" model.change(fn=update_losses, outputs=losses)\n",
|
540 |
"\n",
|
541 |
"demo.launch(debug=True, inline=False)\n",
|
542 |
" # intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=example_images, title=title, description=description )\n",
|
|
|
546 |
},
|
547 |
{
|
548 |
"cell_type": "code",
|
549 |
+
"execution_count": 8,
|
550 |
"id": "cab071f9-7c3b-4b35-a0d1-3687731ffce5",
|
551 |
"metadata": {},
|
552 |
+
"outputs": [
|
553 |
+
{
|
554 |
+
"name": "stdout",
|
555 |
+
"output_type": "stream",
|
556 |
+
"text": [
|
557 |
+
"Export successful\n"
|
558 |
+
]
|
559 |
+
}
|
560 |
+
],
|
561 |
"source": [
|
562 |
"import nbdev\n",
|
563 |
"nbdev.export.nb_export('app.ipynb', './')\n",
|
564 |
"print('Export successful')"
|
565 |
]
|
566 |
+
},
|
567 |
+
{
|
568 |
+
"cell_type": "code",
|
569 |
+
"execution_count": null,
|
570 |
+
"id": "95f0e7ec-edd2-4afa-a68f-7da8b85b1f61",
|
571 |
+
"metadata": {},
|
572 |
+
"outputs": [],
|
573 |
+
"source": []
|
574 |
}
|
575 |
],
|
576 |
"metadata": {
|
app.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
2 |
|
3 |
# %% auto 0
|
4 |
-
__all__ = ['title', 'description', 'learners', 'models', 'active_name', 'active_model', 'example_images', '
|
5 |
-
'
|
6 |
|
7 |
# %% app.ipynb 1
|
8 |
from fastai.vision.all import *
|
@@ -50,12 +50,6 @@ def update_losses():
|
|
50 |
# %% app.ipynb 5
|
51 |
example_images = [ 'cheetah.jpg', 'jaguar.jpg', 'tiger.jpg', 'cougar.jpg', 'lion.jpg', 'african leopard.jpg', 'clouded leopard.jpg', 'snow leopard.jpg', 'hidden.png', 'hidden2.png' ]
|
52 |
|
53 |
-
model_matrix = [ 'models/resnet101-confusion-matrix.png', 'models/resnet18-confusion-matrix.png', 'models/resnet50-confusion-matrix.png',
|
54 |
-
'models/resnet152-confusion-matrix.png', 'models/resnet34-confusion-matrix.png' ]
|
55 |
-
|
56 |
-
model_losses = [ 'models/resnet101-top-losses.png', 'models/resnet18-top-losses.png', 'models/resnet50-top-losses.png',
|
57 |
-
'models/resnet152-top-losses.png', 'models/resnet34-top-losses.png' ]
|
58 |
-
|
59 |
demo = gr.Blocks()
|
60 |
with demo:
|
61 |
with gr.Column(variant="panel"):
|
@@ -69,13 +63,13 @@ with demo:
|
|
69 |
losses=gr.outputs.Image(type='filepath', label="Top Losses")
|
70 |
result = gr.outputs.Label(label="Result")
|
71 |
|
72 |
-
model.change(fn=select_model, inputs=model, outputs=selected)
|
73 |
btnClassify.click(fn=classify_image, inputs=image, outputs=result)
|
74 |
img_gallery = gr.Examples(examples=example_images, inputs=image)
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
79 |
|
80 |
demo.launch(debug=True, inline=False)
|
81 |
# intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=example_images, title=title, description=description )
|
|
|
1 |
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
2 |
|
3 |
# %% auto 0
|
4 |
+
__all__ = ['title', 'description', 'learners', 'models', 'active_name', 'active_model', 'example_images', 'demo',
|
5 |
+
'classify_image', 'select_model', 'update_matrix', 'update_losses']
|
6 |
|
7 |
# %% app.ipynb 1
|
8 |
from fastai.vision.all import *
|
|
|
50 |
# %% app.ipynb 5
|
51 |
example_images = [ 'cheetah.jpg', 'jaguar.jpg', 'tiger.jpg', 'cougar.jpg', 'lion.jpg', 'african leopard.jpg', 'clouded leopard.jpg', 'snow leopard.jpg', 'hidden.png', 'hidden2.png' ]
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
demo = gr.Blocks()
|
54 |
with demo:
|
55 |
with gr.Column(variant="panel"):
|
|
|
63 |
losses=gr.outputs.Image(type='filepath', label="Top Losses")
|
64 |
result = gr.outputs.Label(label="Result")
|
65 |
|
|
|
66 |
btnClassify.click(fn=classify_image, inputs=image, outputs=result)
|
67 |
img_gallery = gr.Examples(examples=example_images, inputs=image)
|
68 |
+
|
69 |
+
# Register all ev
|
70 |
+
model.change(fn=select_model, inputs=model, outputs=selected)
|
71 |
+
model.change(fn=update_matrix, outputs=matrix)
|
72 |
+
model.change(fn=update_losses, outputs=losses)
|
73 |
|
74 |
demo.launch(debug=True, inline=False)
|
75 |
# intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=example_images, title=title, description=description )
|