Todd Roloff commited on
Commit
d35069d
1 Parent(s): 5c59f7d

Add application file

Browse files
Files changed (2) hide show
  1. app.py +25 -0
  2. model.pkl +3 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+
4
+
5
+ def is_cat(x): return x[0].isupper
6
+
7
+
8
+ learn = load_learner('model.pkl')
9
+
10
+ categories = ('Dog', 'Cat')
11
+
12
+
13
+ def classify_image(img):
14
+ pred, idx, probs = learn.predict(img)
15
+ return dict(zip(categories, map(float, probs)))
16
+
17
+
18
+ image = gr.inputs.Image(shape=(192, 192))
19
+ label = gr.outputs.Label()
20
+ examples = ['Dog.jpg', 'Cat.jpg', 'dunno.jpg']
21
+
22
+
23
+ iface = gr.Interface(fn=classify_image, inputs=image,
24
+ outputs=label, examples=examples)
25
+ iface.launch(inline=False)
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b1851de196b8ecbac3a78db06a0712d5f06add14186d324265bcf9820bffc943
3
+ size 47061419