carblacac commited on
Commit
a8e3361
1 Parent(s): fa7e850

change from hello to classify dogs-cats

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