Spaces:
Runtime error
Runtime error
Commit
·
0ca9ab7
1
Parent(s):
66caa7e
Added everything
Browse files- app.py +17 -0
- binder_clip.jpg +0 -0
- calculator.jpg +0 -0
- crayon.jpg +0 -0
- eraser.jpg +0 -0
- glue.jpg +0 -0
- marker.jpg +0 -0
- model_v5_87_percent_final.pkl +3 -0
- paper.jpg +0 -0
- pen.jpg +0 -0
- pencil.jpg +0 -0
- requirements.txt +2 -0
- tape.jpg +0 -0
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
learn = load_learner('model_v5_87_percent_final.pkl')
|
5 |
+
|
6 |
+
categories = ('pencil', 'pen', 'eraser', 'calculator', 'binder clip', 'marker', 'glue', 'tape', 'crayon', 'paper')
|
7 |
+
|
8 |
+
def classify_image(img):
|
9 |
+
pred, idx, probs = learn.predict(img)
|
10 |
+
return dict(zip(categories, map(float, probs)))
|
11 |
+
|
12 |
+
image = gr.inputs.Image(shape=(192, 192))
|
13 |
+
label = gr.outputs.Label()
|
14 |
+
examples = ['pencil.jpg', 'pen.jpg', 'eraser.jpg', 'calculator.jpg', 'binder_clip.jpg', 'marker.jpg', 'glue.jpg', 'tape.jpg', 'crayon.jpg', 'paper.jpg']
|
15 |
+
|
16 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
17 |
+
intf.launch()
|
binder_clip.jpg
ADDED
![]() |
calculator.jpg
ADDED
![]() |
crayon.jpg
ADDED
![]() |
eraser.jpg
ADDED
![]() |
glue.jpg
ADDED
![]() |
marker.jpg
ADDED
![]() |
model_v5_87_percent_final.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8fac109d5f2d7dce4022b8e0bf63c5cf1502453fb15a5559337991f32f8f714d
|
3 |
+
size 102936709
|
paper.jpg
ADDED
![]() |
pen.jpg
ADDED
![]() |
pencil.jpg
ADDED
![]() |
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
gradio
|
tape.jpg
ADDED
![]() |