Spaces:
Runtime error
Runtime error
File size: 472 Bytes
cbb89dc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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() |