heheboi / app.py
Udbenekdkh's picture
Upload app.py
f14ec7f verified
raw
history blame
519 Bytes
import gradio as gr
from transformers import pipeline
# 建立模型
classifier = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
# 預測函式
def predict(image):
predictions = classifier(image)
return {p["label"]: p["score"] for p in predictions}
# 建立介面
gr.Interface(
fn=predict,
inputs=gr.Image(label="Upload hot dog candidate", type="filepath"),
outputs=gr.Label(num_top_classes=2),
title="🌭 Hot Dog? Or Not?",
allow_flagging="manual"
).launch()