CoolFace
Apppublic

dominguezdaniel/image-recognition

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes
app.py16 linesDownload Raw Back to root
1import gradio as gr2from transformers import pipeline3 4def predict(image):5    model_id = "google/vit-base-patch16-224"6    classifier = pipeline("image-classification", model=model_id)7    predictions = classifier(image)8    return {prediction['label']: prediction['score'] for prediction in predictions}9 10title = "Image Rocognition"11description = "A demo that recognizes and classifies images using the model from Hugging Face's 'google/vit-base-patch16-224'."12input_component = gr.Image(type="filepath", label="Upload an image here")13output_component = gr.Label(num_top_classes=3)14 15gr.Interface(fn=predict, inputs=input_component, outputs=output_component, title=title, description=description).launch()16