ZQxwce commited on
Commit
10a2318
1 Parent(s): 0cd4245

cat or dog ? in production

Browse files

machine learning in production .
determine if a given image is a cat or a dog or donno.

Files changed (1) hide show
  1. app.py +19 -5
app.py CHANGED
@@ -1,6 +1,20 @@
1
- import gradio as gr
2
- def greet(name):
3
- return "Hello " + name + "!!"
4
 
5
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
6
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)