dominguezdaniel's picture
Update app.py
9105495 verified
raw
history blame
No virus
701 Bytes
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()