29 lines
1007 B
Python
29 lines
1007 B
Python
import gradio as gr
|
|
from transformers import pipeline
|
|
|
|
def inference(sequence_to_classify):
|
|
model_path="mDeBERTa-v3-base-mnli-xnli"
|
|
classifier = pipeline("zero-shot-classification", model=model_path)
|
|
|
|
candidate_labels = ["politics", "economy", "entertainment", "environment"]
|
|
output = classifier(sequence_to_classify, candidate_labels, multi_label=False)
|
|
return output
|
|
|
|
|
|
examples=[["Angela Merkel ist eine Politikerin in Deutschland und Vorsitzende der CDU"]]
|
|
|
|
with gr.Blocks() as demo:
|
|
gr.Markdown(
|
|
"""
|
|
# Text classification:mDeBERTa-v3-base-mnli-xnli
|
|
这是mDeBERTa-v3-base-mnli-xnli的Gradio Demo。输入你想要的英文文本或者点击下面的示例文本来加载它。
|
|
""")
|
|
with gr.Row():
|
|
text_input = gr.Textbox()
|
|
text_output = gr.Textbox()
|
|
image_button = gr.Button("上传")
|
|
image_button.click(inference, inputs=text_input, outputs=text_output)
|
|
gr.Examples(examples,inputs=text_input)
|
|
|
|
demo.launch(server_name="0.0.0.0")
|