danieladejumo commited on
Commit
d3aa858
1 Parent(s): bacdcbf

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+ learn = load_learner("classifier.pkl")
5
+
6
+ labels = learn.dls.vocab
7
+ examples = ['dolphin.jpg', 'shark.jpg', 'whale.jpg']
8
+
9
+ def predict(img_file):
10
+ img = PILImage.create(img_file)
11
+ pred, idx, probs = learn.predict(img)
12
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
+
14
+ gr.Interface(fn=predict,
15
+ inputs=gr.inputs.Image(shape=(512,512)),
16
+ outputs=gr.outputs.Label(num_top_classes=3),
17
+ examples=examples).launch(share=True, debug=False)