Spaces:
Sleeping
Sleeping
File size: 519 Bytes
f14ec7f |
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="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()
|