File size: 701 Bytes
d967560
228b53a
d967560
228b53a
 
 
9105495
 
d967560
228b53a
 
b3f3e2f
 
d967560
b3f3e2f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gradio as gr
from transformers import pipeline

def predict(image):
    model_id = "google/vit-base-patch16-224"
    classifier = pipeline("image-classification", model=model_id)
    predictions = classifier(image)
    return {prediction['label']: prediction['score'] for prediction in predictions}

title = "Image Classifier"
description = "A demo that recognizes and classifies images using the model from Hugging Face's 'google/vit-base-patch16-224'."
input_component = gr.Image(type="pil", label="Upload an image here")
output_component = gr.Label(num_top_classes=3)

gr.Interface(fn=predict, inputs=input_component, outputs=output_component, title=title, description=description).launch()