Jade Choghari commited on
Commit
b7a9168
·
1 Parent(s): aed4ce3
Files changed (2) hide show
  1. .gitignore +1 -0
  2. app.py +21 -4
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ ./model.pkl
app.py CHANGED
@@ -1,7 +1,24 @@
 
 
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
+ #train
8
+ learn = load_learner('model.pkl')
9
+
10
+ #|export
11
+ categories = ('Dog', 'Cat')
12
+
13
+ def classify_image(img):
14
+ pred,idx,probs = learn.predict(img)
15
+ # dict of a zip - map
16
+ return dict(zip(categories, map(float, probs)))
17
+
18
+ #|export
19
+ image = gr.inputs.Image(shape=(192, 192))
20
+ label = gr.outputs.Label()
21
+ examples = ['dog.jpg', 'cat.jpeg', 'dunno.jpg']
22
+
23
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
24
+ intf.launch(inline=False)