simecek commited on
Commit
470e368
·
1 Parent(s): 3850f8e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ from gradio import Interface, components
3
+
4
+ learn = load_learner('model.pkl')
5
+ categories = learn.dls.vocab
6
+ examples = ['bird.jpg']
7
+
8
+ # function for the prediction
9
+ def classify_image(img):
10
+ pred,idx,probs = learn.predict(img)
11
+ return dict(zip(categories, map(float,probs)))
12
+
13
+ image = components.Image(shape=(192, 192))
14
+ label = components.Label()
15
+
16
+ intf = Interface(
17
+ fn=classify_image, inputs=[image], outputs=[label], examples=examples
18
+ )
19
+
20
+ intf.launch(debug=True)