Pablogps commited on
Commit
960415a
1 Parent(s): 0221e9d

Create 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 = "Antique furniture style predictor"
16
+ description = "A small model for prediction of furniture style."
17
+ examples = ['jacobean.jpg', 'art_deco.jpg', 'sheraton.jpg']
18
+
19
+ gr.Interface(
20
+ fn=predict,
21
+ inputs=gr.Image(),
22
+ outputs=gr.Label(num_top_classes=3),
23
+ title=title,
24
+ description=description,
25
+ examples=examples,
26
+ ).launch()
27
+ iface.launch()