Update app.py
Browse files
app.py
CHANGED
@@ -3,3 +3,20 @@ import gradio as gr
|
|
3 |
|
4 |
classifier = pipeline("zero-shot-classification", model="DeepPavlov/xlm-roberta-large-en-ru-mnli")
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
classifier = pipeline("zero-shot-classification", model="DeepPavlov/xlm-roberta-large-en-ru-mnli")
|
5 |
|
6 |
+
def wrap_classifier(text, labels, template):
|
7 |
+
labels = labels.split(",")
|
8 |
+
outputs = classifier(text, labels, hypothesis_template=template)
|
9 |
+
return outputs["labels"][0]
|
10 |
+
|
11 |
+
gr.Interface(
|
12 |
+
fn=wrap_classifier,
|
13 |
+
title="Zero-shot Classification",
|
14 |
+
inputs=[
|
15 |
+
gr.inputs.Textbox(lines=5, label="Text to classify"),
|
16 |
+
gr.inputs.Textbox(lines=1, label="Candidate labels separated with commas"),
|
17 |
+
gr.inputs.Textbox(lines=1, label="Template", default="This sentence is about {}.", placeholder="This sentence is about {}.")
|
18 |
+
],
|
19 |
+
outputs=[
|
20 |
+
gr.outputs.Textbox(label="Label")
|
21 |
+
],
|
22 |
+
).launch()
|