deployapp commited on
Commit
e55c3b2
1 Parent(s): 2c396d2

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+
5
+ def get_x(r): return path/r['fname']
6
+ def get_y(r): return r['car_body_style']
7
+
8
+ learn = load_learner('export.pkl')
9
+
10
+ labels = learn.dls.vocab
11
+
12
+ def predict(img):
13
+ img = PILImage.create(img)
14
+ pred, pred_idx, probs = learn.predict(img)
15
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
16
+
17
+ title = 'Car Body Style Classifier'
18
+ description = 'A car body style classifier trained on the [Cars Dataset](http://ai.stanford.edu/~jkrause/cars/car_dataset.html).'
19
+
20
+ examples = ['convertible.jpg', 'coupe.jpg', 'van.jpg']
21
+
22
+ gr.Interface(fn=predict,
23
+ inputs=gr.inputs.Image(shape=(512, 512)),
24
+ outputs=gr.outputs.Label(num_top_classes=3),
25
+ title=title, description=description,
26
+ examples=examples,
27
+ enable_queue=True).launch(share=True)