montanoj96 commited on
Commit
09162a0
1 Parent(s): ad4bfed

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+ # dependent function
5
+ # labeling function
6
+ def is_cat(x):
7
+ return x[0].isupper()
8
+
9
+
10
+ learn = load_learner('model.pkl')
11
+
12
+
13
+
14
+ categories = ('Dog', 'Cat')
15
+
16
+ # function to classify image
17
+ def classify_image(img):
18
+ pred, idx, probs = learn.predict(img)
19
+ return dict(zip(categories, map(float, probs)))
20
+
21
+ image = gr.inputs.Image(shape=(192,192))
22
+ label = gr.outputs.Label()
23
+ # examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
24
+
25
+ # gradio interface what kind of ouput
26
+ # input and output
27
+ # can provide some examples
28
+ # the gradio interface can take different kinds of inputs
29
+ intf = gr.Interface(fn=classify_image, inputs = image, outputs=label)#, examples = examples)
30
+ intf.launch(inline = False)
31
+
32
+
33
+
34
+