dominguezdaniel's picture
Update app.py
db730ff verified
raw
history blame contribute delete
707 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 Rocognition"
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="filepath", 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()