Spaces:
Runtime error
Runtime error
Changes to the app.py
Browse files
app.py
CHANGED
|
@@ -4,19 +4,16 @@ import gradio as gr
|
|
| 4 |
|
| 5 |
learn = from_pretrained_fastai("robinsk8a/exotic_cars_classifier")
|
| 6 |
|
| 7 |
-
|
| 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 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
| 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()
|