This commit is contained in:
SOULOFCINDER 2023-03-31 13:02:25 +08:00
commit f29aa95b1d
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,28 @@
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
Gradio Demo for mDeBERTa-v3-base-mnli-xnli. To use it, simply type in text, or click one of the examples to load them.
""")
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()

@ -0,0 +1 @@
Subproject commit 9086d78af18a62546cf05a768934d291684d6309