Spaces:
Running
on
Zero
Running
on
Zero
Lord-Raven
commited on
Commit
·
d04fba3
1
Parent(s):
93643d5
Trying zero-shot classification.
Browse files
app.py
CHANGED
|
@@ -1,10 +1,15 @@
|
|
| 1 |
import gradio
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
gradio_interface = gradio.Interface(
|
| 6 |
fn = zero_shot_classification,
|
| 7 |
-
inputs = "
|
| 8 |
-
outputs = "
|
| 9 |
)
|
| 10 |
gradio_interface.launch()
|
|
|
|
| 1 |
import gradio
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
def zero_shot_classification(data):
|
| 5 |
+
classifier = pipeline('zero-shot-classification, model='Xenova/mobilebert-uncased-mnli')
|
| 6 |
+
|
| 7 |
+
results = classifier(data.sequence, candidate_labels=data.candidate_labels, hypothesis_template=data.hypothesis_template, multi_label=data.multi_label)
|
| 8 |
+
return {results}
|
| 9 |
|
| 10 |
gradio_interface = gradio.Interface(
|
| 11 |
fn = zero_shot_classification,
|
| 12 |
+
inputs = "json",
|
| 13 |
+
outputs = "json"
|
| 14 |
)
|
| 15 |
gradio_interface.launch()
|