Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,16 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
|
| 5 |
+
|
| 6 |
+
def classify(text, labels):
|
| 7 |
+
return classifier(text, candidate_labels=labels)
|
| 8 |
+
|
| 9 |
+
iface = gr.Interface(
|
| 10 |
+
fn=classify,
|
| 11 |
+
inputs=[gr.Text(label="Text"), gr.Textbox(lines=1, label="Candidate Labels (comma-separated)")],
|
| 12 |
+
outputs="json"
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
if __name__ == "__main__":
|
| 16 |
+
iface.launch()
|