Arman511 commited on
Commit
c1557ab
·
1 Parent(s): 980aebb

Upload app.py

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