jojortz commited on
Commit
f40b2ec
1 Parent(s): 78a976b

add dog vs. cat model

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