Spaces:
Sleeping
Sleeping
| 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() |