jidangdang commited on
Commit
cbb89dc
·
verified ·
1 Parent(s): 00278c5

Create 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
+ model_name = "climatebert/distilroberta-base-climate-detector"
6
+ pipe = pipeline("text-classification", model=model_name)
7
+
8
+ # 定义分类函数
9
+ def classify_text(text):
10
+ return pipe(text)
11
+
12
+ # 创建 Gradio 界面
13
+ iface = gr.Interface(
14
+ fn=classify_text,
15
+ inputs=gr.Textbox(lines=2, placeholder="输入文本..."),
16
+ outputs="json",
17
+ title="气候文本分类器"
18
+ )
19
+ iface.launch()