Spaces:
Running
Running
| import gradio as gr | |
| from transformers import pipeline | |
| # β δ½Ώη¨ιη¨ζ¨‘εδΎει‘δΈεͺη±ηηεη | |
| classifier = pipeline(task="image-classification", model="google/vit-base-patch16-224") | |
| def predict(input_img): | |
| predictions = classifier(input_img) | |
| return input_img, {p["label"]: p["score"] for p in predictions} | |
| gradio_app = gr.Interface( | |
| fn=predict, | |
| inputs=gr.Image(label="Upload an image", sources=['upload', 'webcam'], type="pil"), | |
| outputs=[gr.Image(label="Input Image"), gr.Label(label="Predictions", num_top_classes=3)], | |
| title="π½οΈ Image Classifier β What Is This?", | |
| ) | |
| if __name__ == "__main__": | |
| gradio_app.launch() | |