Spaces:
Sleeping
Sleeping
Prasanthin
commited on
Commit
·
ea85fbd
1
Parent(s):
9483c15
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,26 @@
|
|
1 |
|
|
|
|
|
|
|
2 |
from fastai.vision.all import *
|
3 |
import gradio as gr
|
4 |
-
def is_cat(x):return x[0].isupper()
|
5 |
-
|
6 |
-
learn=load_learner('model.pkl')
|
7 |
-
categories=('Dog','Cat')
|
8 |
-
def classify_image(img):
|
9 |
-
pred,ind,probs=learn.predict(img)
|
10 |
-
return dict(zip(categories,map(float,probs)))
|
11 |
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
gr.Interface(fn=classify_image,inputs=image,outputs=label)
|
|
|
|
1 |
|
2 |
+
__all__ = ['is_cat', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
|
3 |
+
|
4 |
+
# Cell
|
5 |
from fastai.vision.all import *
|
6 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
+
def is_cat(x): return x[0].isupper()
|
9 |
+
|
10 |
+
# Cell
|
11 |
+
learn = load_learner('model.pkl')
|
12 |
+
|
13 |
+
# Cell
|
14 |
+
categories = ('Dog', 'Cat')
|
15 |
+
|
16 |
+
def classify_image(img):
|
17 |
+
pred,idx,probs = learn.predict(img)
|
18 |
+
return dict(zip(categories, map(float,probs)))
|
19 |
|
20 |
+
# Cell
|
21 |
+
image = gr.inputs.Image(shape=(192, 192))
|
22 |
+
label = gr.outputs.Label()
|
23 |
+
examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
|
24 |
|
25 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
26 |
+
intf.launch(inline=False)
|