AK4VER commited on
Commit
411fc5d
1 Parent(s): 424e27a

Updated model

Browse files
Files changed (1) hide show
  1. app.py +27 -4
app.py CHANGED
@@ -1,7 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # 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()
8
+
9
+
10
+ __all__ = ['is_cat', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
11
+
12
+ from fastai.vision.all import *
13
  import gradio as gr
14
 
15
+ def is_cat(x): return x[0].isupper()
16
+
17
+ learn = load_learner('model.pkl')
18
+
19
+ categories = ('Dog', 'Cat')
20
+
21
+ def classify_image(img):
22
+ pred, idx, probs = learn.predict(img)
23
+ return dict(zip(categories, map(float, probs)))
24
+
25
+ image = gr.inputs.Image(shape=(192, 192))
26
+ label = gr.outputs.Label()
27
+ examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
28
 
29
+ intf = gr.Interface(fn = classify_image, inputs = image, outputs = label, examples = examples)
30
+ intf.launch(inline = False)