Spaces:
Runtime error
Runtime error
Gradio app actualized with examples, title, image recognition and description
Browse files- app.py +17 -4
- bmw.jpg +0 -0
- koenigsegg.jpg +0 -0
- lamborghini.jpg +0 -0
- requirements.txt +2 -0
app.py
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
learn = load_learner('sport_car_classifier.pkl')
|
| 5 |
+
labels = learn.dls.vocab
|
| 6 |
+
def predict(img):
|
| 7 |
+
img = PILImage.create(img)
|
| 8 |
+
pred,pred_idx,probs = learn.predict(img)
|
| 9 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 10 |
|
| 11 |
+
gr.Interface(
|
| 12 |
+
fn=predict,
|
| 13 |
+
inputs=gr.inputs.Image(
|
| 14 |
+
shape=(512, 512)),
|
| 15 |
+
outputs=gr.outputs.Label(num_top_classes=3),
|
| 16 |
+
title="Sport car classifier",
|
| 17 |
+
description="An app design to classifie the most relateve sportcars",
|
| 18 |
+
examples=['bmw.jpg', 'lamborghini.jpg', 'koenigsegg.jpg'],
|
| 19 |
+
interpretation='default',
|
| 20 |
+
enable_queue=True).launch(share=True)
|
bmw.jpg
ADDED
|
koenigsegg.jpg
ADDED
|
lamborghini.jpg
ADDED
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastai
|
| 2 |
+
scikit-image
|