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