Spaces:
Runtime error
Runtime error
Sadia commited on
Commit ·
ce6b8c9
1
Parent(s): 3fbe06e
prediction model
Browse files
app.py
CHANGED
|
@@ -1,11 +1,22 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
learn = load_learner('model.pkl')
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
+
|
| 3 |
+
def is_cat(x): return x[0].isupper()
|
| 4 |
+
|
| 5 |
+
im = PILImage.create('dog.jpeg')
|
| 6 |
+
im.thumbnail((192,192))
|
| 7 |
+
im
|
| 8 |
|
| 9 |
learn = load_learner('model.pkl')
|
| 10 |
+
categories = ('Dog', 'Cat')
|
| 11 |
|
| 12 |
+
def classify_image(img):
|
| 13 |
+
pred,idx,probs = learn.predict(img)
|
| 14 |
+
return dict(zip(categories, map(float,probs)))
|
| 15 |
+
|
| 16 |
+
import gradio as gr
|
| 17 |
|
| 18 |
+
image = gr.inputs.Image(shape=(192,192))
|
| 19 |
+
label = gr.outputs.Label()
|
| 20 |
+
examples = ['dog.jpg', 'cat.jpg']
|
| 21 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 22 |
+
intf.launch(inline=False, share=True)
|
cat.jpeg
ADDED
|
cat2.jpeg
ADDED
|
dog.jpeg
ADDED
|
dog2.jpeg
ADDED
|