Kazumi commited on
Commit
1f62a1c
·
verified ·
1 Parent(s): 5303968

Initial commit

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