Spaces:
Sleeping
Sleeping
File size: 594 Bytes
8bf433a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 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() |