Spaces:
Sleeping
Sleeping
Ivan Andrianto
commited on
Commit
·
68d627f
1
Parent(s):
883a0c3
Add application file
Browse files
app.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
from PIL import Image
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def get_result_by_image(input_image: gr.Image) -> dict:
|
| 7 |
+
pipe = pipeline("image-classification", model="ivandrian11/vit-fruit-classifier")
|
| 8 |
+
|
| 9 |
+
image = Image.fromarray(input_image)
|
| 10 |
+
print(pipe(image))
|
| 11 |
+
|
| 12 |
+
sorted_data = sorted(pipe(image), key=lambda x: x["score"], reverse=True)
|
| 13 |
+
return sorted_data[0]
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
iface = gr.Interface(fn=get_result_by_image, inputs="image", outputs="text")
|
| 17 |
+
iface.launch()
|