Spaces:
Sleeping
Sleeping
File size: 669 Bytes
08a1a2e b27155d 08a1a2e b27155d 08a1a2e b27155d 08a1a2e b27155d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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()
|