Cbhandawat commited on
Commit
3cdb41d
1 Parent(s): d98e7c9

adding model and images

Browse files
Files changed (4) hide show
  1. app.py +18 -4
  2. cat.jpg +0 -0
  3. dog.jpg +0 -0
  4. dunno.jpg +0 -0
app.py CHANGED
@@ -1,7 +1,21 @@
 
 
 
 
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
1
+ __all__ = ['is_cat', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
2
+
3
+
4
+
5
+ from fastai.vision.all import *
6
  import gradio as gr
7
 
8
+ def is_cat(x): return x[0].isupper()
9
+
10
+ learn = load_learner('model.pkl')
11
+
12
+ categories = ('Dog', 'Cat')
13
+
14
+ def classify_image(img):
15
+ pred, idx, probs = learn.predict(img)
16
+ return dict(zip(categories, map(float,probs)))
17
+
18
+ intf = gr.Interface(fn=classify_image, inputs=gr.Image(type="pil"), outputs=gr.Label(),examples=['dog.jpg', 'cat.jpg', 'dunno.jpg'])
19
+ intf.launch(inline=False)
20
+
21
 
 
 
cat.jpg ADDED
dog.jpg ADDED
dunno.jpg ADDED