Spaces:
Sleeping
Sleeping
Create app.py
Browse files12345678910111213141516171819202122import gradio as grfrom transformers import pipeline
# Load a pre-trained image classification model from Hugging Facemodel = pipeline("image-classification", model="google/vit-base-patch16-224")
# Define the prediction functiondef classify_image(image): predictions = model(image) return {pred["label"]: pred["score"] for pred in predictions}
# Gradio Interfacedemo = gr.Interface( fn=classify_image, inputs=gr.Image(type="pil"), outputs=gr.Label(num_top_classes=5), title="Image Recognition AI", description="Upload an image to classify it using a pre-trained model from Hugging Face.")
# Launch the appdemo.launch()app.pyAdded+22