stomlins commited on
Commit
ef77367
1 Parent(s): 9fbeaac
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -1,7 +1,21 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from fastai.vision.all import *
3
 
4
+ path = Path()
5
+ learn_inf = load_learner(path / 'export.pkl')
6
 
7
+ labels = ['beach', 'field', 'lake']
8
+
9
+ def predict(img):
10
+ img = PILImage.create(img)
11
+ pred, pred_idx, probs = learn_inf.predict(img)
12
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
+
14
+
15
+ gr_interface = gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)),
16
+ outputs=gr.outputs.Label(num_top_classes=len(labels)), interpretation="default")
17
+
18
+ gr_interface = gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)),
19
+ outputs=gr.outputs.Label(num_top_classes=len(labels)),
20
+ interpretation="default")
21
+ gr_interface.launch()