pvasudev commited on
Commit
9505fe3
1 Parent(s): 72f1bd5

Add app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+
4
+ import fastbook
5
+ import gradio
6
+ import PIL
7
+ import gradio as gr
8
+
9
+ learner = fastbook.load_learner("./zidane_scholes_mbappe.pkl")
10
+
11
+ labels = learner.dls.vocab
12
+ labels
13
+
14
+ def predict(img):
15
+ # img = fastbook.PILImage.create(img)
16
+ pred, pred_idx, probs = learner.predict(img)
17
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
18
+
19
+ gr.Interface(
20
+ fn=predict,
21
+ inputs=gr.inputs.Image(shape=(512, 512)),
22
+ outputs=gr.outputs.Label(num_top_classes=3)
23
+ ).launch(
24
+ share=True
25
+ )
26
+
27
+