Spaces:
Runtime error
Runtime error
Download app.py from ivandrian11/PredictFruit: direct link, hf CLI and curl.
- Browser
- Download file 484 Bytes
-
https://huggingface.co/spaces/ivandrian11/PredictFruit/resolve/main/app.py
- Command line
-
hf download hf://spaces/ivandrian11/PredictFruit/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ivandrian11/PredictFruit/resolve/main/app.py
484 Bytes
| from transformers import pipeline | |
| from PIL import Image | |
| import gradio as gr | |
| def get_result_by_image(input_image: gr.Image) -> dict: | |
| pipe = pipeline("image-classification", model="ivandrian11/vit-fruit-classifier") | |
| image = Image.fromarray(input_image) | |
| print(pipe(image)) | |
| sorted_data = sorted(pipe(image), key=lambda x: x["score"], reverse=True) | |
| return sorted_data[0] | |
| iface = gr.Interface(fn=get_result_by_image, inputs="image", outputs="json") | |
| iface.launch() | |