Test / app.py
jidangdang's picture
Create app.py
cbb89dc verified
raw
history blame contribute delete
472 Bytes
import gradio as gr
from transformers import pipeline
# 加载模型和分词器
model_name = "climatebert/distilroberta-base-climate-detector"
pipe = pipeline("text-classification", model=model_name)
# 定义分类函数
def classify_text(text):
return pipe(text)
# 创建 Gradio 界面
iface = gr.Interface(
fn=classify_text,
inputs=gr.Textbox(lines=2, placeholder="输入文本..."),
outputs="json",
title="气候文本分类器"
)
iface.launch()