Hot-Dog-Or-Not / app.py
Udbenekdkh's picture
Update app.py
b27155d verified
raw
history blame
669 Bytes
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()