NLTuan commited on
Commit
93b2417
·
1 Parent(s): 9e62a0f

recognizer add

Browse files
Files changed (1) hide show
  1. app.py +26 -6
app.py CHANGED
@@ -1,7 +1,27 @@
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
+ from fastai.vision.all import *
3
+
4
+ def greet(name):
5
+ return "Hello " + name + "!!!"
6
+
7
+ def is_cat(x):
8
+ return x[0].isupper()
9
+
10
+ im = PILImage.create("dog.jpg")
11
+ im.thumbnail((192,192))
12
+ learner = load_learner("model.pkl")
13
+
14
+ categories = ("Dog", "Cat")
15
+
16
+ def classify_image(img):
17
+ pred, ind, probs = learner.predict(img)
18
+ return dict(zip(categories,map(float,probs)))
19
+
20
+
21
+ print(classify_image(im))
22
+
23
+ image = gr.input.Image(shape = (192, 192))
24
+ label = gr.outputs.Label()
25
+ examples = ["dog.jpg", "cat.jpg", "dogcat.jpg"]
26
+ iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples =examples)
27
  iface.launch()