Spaces:
Runtime error
Runtime error
cat or dog ? in production
Browse filesmachine learning in production .
determine if a given image is a cat or a dog or donno.
app.py
CHANGED
@@ -1,6 +1,20 @@
|
|
1 |
-
import
|
2 |
-
|
3 |
-
return "Hello " + name + "!!"
|
4 |
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import fastai.vision.all import *
|
2 |
+
import gradio as gr
|
|
|
3 |
|
4 |
+
def is_cat(x): return x[0].isupper()
|
5 |
+
|
6 |
+
learn = load_learner ('model.pkl')
|
7 |
+
|
8 |
+
categories = ('dog','cat')
|
9 |
+
|
10 |
+
|
11 |
+
def classify_image(img):
|
12 |
+
pred,idx,probs = learn.predict(img)
|
13 |
+
return dict(zip(categories,map(float,probs)))
|
14 |
+
|
15 |
+
image = gr.input.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,output=label, examples= examples)
|
20 |
+
intf.launch(inline=false)
|