Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,6 @@
|
|
| 4 |
|
| 5 |
# In[7]:
|
| 6 |
|
| 7 |
-
|
| 8 |
#|export
|
| 9 |
from fastai.vision.all import *
|
| 10 |
import gradio as gr
|
|
@@ -14,27 +13,24 @@ def is_cat(x): return x[0].isupper()
|
|
| 14 |
|
| 15 |
# In[9]:
|
| 16 |
|
| 17 |
-
|
| 18 |
#|export
|
| 19 |
learn = load_learner('model.pkl')
|
| 20 |
|
| 21 |
|
| 22 |
-
|
| 23 |
# In[12]:
|
| 24 |
|
| 25 |
-
|
| 26 |
#|export
|
| 27 |
categories = ('Dog', 'Cat')
|
| 28 |
|
| 29 |
def classify_image(img):
|
| 30 |
-
pred,idx,probs = learn.predict(img)
|
| 31 |
-
return dict(zip(categories, map(float,probs)))
|
| 32 |
|
| 33 |
|
| 34 |
#|export
|
| 35 |
-
image = gr.Image(shape=(192, 192))
|
| 36 |
-
label = gr.Label()
|
| 37 |
examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
|
| 38 |
|
| 39 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 40 |
-
intf.launch(inline=False, share=True)
|
|
|
|
| 4 |
|
| 5 |
# In[7]:
|
| 6 |
|
|
|
|
| 7 |
#|export
|
| 8 |
from fastai.vision.all import *
|
| 9 |
import gradio as gr
|
|
|
|
| 13 |
|
| 14 |
# In[9]:
|
| 15 |
|
|
|
|
| 16 |
#|export
|
| 17 |
learn = load_learner('model.pkl')
|
| 18 |
|
| 19 |
|
|
|
|
| 20 |
# In[12]:
|
| 21 |
|
|
|
|
| 22 |
#|export
|
| 23 |
categories = ('Dog', 'Cat')
|
| 24 |
|
| 25 |
def classify_image(img):
|
| 26 |
+
pred, idx, probs = learn.predict(img)
|
| 27 |
+
return dict(zip(categories, map(float, probs)))
|
| 28 |
|
| 29 |
|
| 30 |
#|export
|
| 31 |
+
image = gr.components.Image(shape=(192, 192)) # Updated component syntax
|
| 32 |
+
label = gr.components.Label() # Updated component syntax
|
| 33 |
examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
|
| 34 |
|
| 35 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 36 |
+
intf.launch(inline=False, share=True)
|