Spaces:
Runtime error
Runtime error
Download app.py from Udyan/ImageClassification: direct link, hf CLI and curl.
- Browser
- Download file 594 Bytes
-
https://huggingface.co/spaces/Udyan/ImageClassification/resolve/main/app.py
- Command line
-
hf download hf://spaces/Udyan/ImageClassification/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Udyan/ImageClassification/resolve/main/app.py
594 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| classifier = pipeline( | |
| "image-classification", | |
| model="google/vit-base-patch16-224" | |
| ) | |
| def classify_image(image): | |
| results = classifier(image) | |
| output = "" | |
| for item in results[:5]: | |
| output += f"{item['label']} : {item['score']:.2%}\n" | |
| return output | |
| demo = gr.Interface( | |
| fn=classify_image, | |
| inputs=gr.Image(type="pil"), | |
| outputs=gr.Textbox(label="Classification Results"), | |
| title="Image Classification App", | |
| description="Upload an image and let AI identify what it contains." | |
| ) | |
| demo.launch() |