Tort73 commited on
Commit
a9c8ea3
·
1 Parent(s): e6b7b96

Initial commit

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.learner import load_learner
3
+ from fastai.vision.all import *
4
+
5
+ learner_inf = load_learner('banana.pkl')
6
+
7
+ labels = learner_inf.dls.vocab
8
+
9
+
10
+ def predict(img):
11
+ img = PILImage.create(img)
12
+ pred, pred_idx, probs = learner_inf.predict(img)
13
+ return {label: float(probs[i]) for i, label in enumerate(labels)}
14
+
15
+ gr.Interface(
16
+ fn=predict,
17
+ inputs=gr.inputs.Image(shape=(192,192)),
18
+ outputs=gr.outputs.Label(num_top_classes=3)
19
+ ).launch(share=True)