robinsk8a commited on
Commit
356f3df
·
1 Parent(s): db6920d

Changes to the app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -15
app.py CHANGED
@@ -4,19 +4,16 @@ import gradio as gr
4
 
5
  learn = from_pretrained_fastai("robinsk8a/exotic_cars_classifier")
6
 
7
- labels = learn.dls.vocab
8
- def predict(img):
9
- img = PILImage.create(img)
10
- pred,pred_idx,probs = learn.predict(img)
11
- return {labels[i]: float(probs[i]) for i in range(len(labels))}
12
 
13
- gr.Interface(
14
- fn=predict,
15
- inputs=gr.inputs.Image(
16
- shape=(512, 512)),
17
- outputs=gr.outputs.Label(num_top_classes=3),
18
- title="Sport car classifier",
19
- description="An app design to classifie the most relateve sportcars",
20
- examples=['bmw.jpg', 'lamborghini.jpg', 'koenigsegg.jpg'],
21
- interpretation='default',
22
- enable_queue=True).launch(share=True)
 
 
4
 
5
  learn = from_pretrained_fastai("robinsk8a/exotic_cars_classifier")
6
 
7
+ categories = ('Dog', 'Cat''ferrari','lamborghini','mclaren','aston martin','koenigsegg','porsche','pagani')
 
 
 
 
8
 
9
+ def classify_image(img):
10
+ pred,idx,probs = learn.predict(img)
11
+ return dict(zip(categories, map(float,probs)))
12
+
13
+
14
+ image = gr.inputs.Image(shape=(192, 192))
15
+ label = gr.outputs.Label()
16
+ examples=['bmw.jpg', 'lamborghini.jpg', 'koenigsegg.jpg'],
17
+
18
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
19
+ intf.launch()