yaizaa commited on
Commit
86ca638
·
verified ·
1 Parent(s): cc7f504

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+
4
+
5
+ learn = load_learner('model.pkl')
6
+ labels = learn.dls.vocab
7
+
8
+
9
+ def predict(img):
10
+ img = PILImage.create(img)
11
+ pred, pred_idx, probs = learn.predict(img)
12
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
+
14
+
15
+ title = "Gradio test"
16
+ description = "Quick Fastai classifier for Disney Channel old series."
17
+ examples = ['lizzie4.jpg', 'raven4.jpg', 'waverly.jgp', 'hannahmontana.jgp', 'tvsuite2.jpg',]
18
+
19
+ gr.Interface(
20
+ fn=predict,
21
+ inputs=gr.Image(),
22
+ outputs=gr.Label(num_top_classes=2),
23
+ title=title,
24
+ description=description,
25
+ examples=examples,
26
+ ).launch()
27
+ iface.launch()