Jet-12138 commited on
Commit
5df6d8e
·
verified ·
1 Parent(s): 217e2d4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # 加载你的模型
5
+ classifier = pipeline("text-classification", model="你的用户名/你的模型名")
6
+
7
+ # 定义推理函数
8
+ def classify(text):
9
+ outputs = classifier(text)
10
+ # 可以只返回预测标签
11
+ return outputs[0]["label"]
12
+
13
+ # 创建Gradio界面
14
+ iface = gr.Interface(fn=classify,
15
+ inputs=gr.Textbox(lines=2, placeholder="输入文本..."),
16
+ outputs="text",
17
+ title="文本分类模型",
18
+ description="请输入一段文本,我来帮你分类!")
19
+
20
+ iface.launch()