Spaces:
Runtime error
Runtime error
trying pipeline
Browse files
app.py
CHANGED
|
@@ -1,19 +1,15 @@
|
|
| 1 |
-
from fastai.vision.all import *
|
| 2 |
-
from huggingface_hub import push_to_hub_fastai, from_pretrained_fastai
|
| 3 |
import gradio as gr
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 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()
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
pipeline = pipeline(task="image-classification", model="robinsk8a/exotic_cars_classifier")
|
| 5 |
|
| 6 |
+
def predict(image):
|
| 7 |
+
predictions = pipeline(image)
|
| 8 |
+
return {p["label"]: p["score"] for p in predictions}
|
| 9 |
|
| 10 |
+
gr.Interface(
|
| 11 |
+
predict,
|
| 12 |
+
inputs=gr.inputs.Image(label="Upload the car you want to guess", type="filepath"),
|
| 13 |
+
outputs=gr.outputs.Label(num_top_classes=3),
|
| 14 |
+
title="Exotic car classifier",
|
| 15 |
+
).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|