Udbenekdkh commited on
Commit
f14ec7f
·
verified ·
1 Parent(s): f6b80c4

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # 建立模型
5
+ classifier = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
6
+
7
+ # 預測函式
8
+ def predict(image):
9
+ predictions = classifier(image)
10
+ return {p["label"]: p["score"] for p in predictions}
11
+
12
+ # 建立介面
13
+ gr.Interface(
14
+ fn=predict,
15
+ inputs=gr.Image(label="Upload hot dog candidate", type="filepath"),
16
+ outputs=gr.Label(num_top_classes=2),
17
+ title="🌭 Hot Dog? Or Not?",
18
+ allow_flagging="manual"
19
+ ).launch()