Spaces:
Running
on
Zero
Running
on
Zero
Lord-Raven
commited on
Commit
·
daac94f
1
Parent(s):
47a0109
Trying zero-shot classification.
Browse files
app.py
CHANGED
|
@@ -2,7 +2,9 @@ import gradio
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
def zero_shot_classification(data_string):
|
|
|
|
| 5 |
data = json.loads(data_string)
|
|
|
|
| 6 |
classifier = pipeline('zero-shot-classification', model='Xenova/mobilebert-uncased-mnli')
|
| 7 |
|
| 8 |
results = classifier(data.sequence, candidate_labels=data.candidate_labels, hypothesis_template=data.hypothesis_template, multi_label=data.multi_label)
|
|
@@ -10,7 +12,7 @@ def zero_shot_classification(data_string):
|
|
| 10 |
|
| 11 |
gradio_interface = gradio.Interface(
|
| 12 |
fn = zero_shot_classification,
|
| 13 |
-
inputs = "
|
| 14 |
outputs = "json"
|
| 15 |
)
|
| 16 |
gradio_interface.launch()
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
def zero_shot_classification(data_string):
|
| 5 |
+
print(data_string)
|
| 6 |
data = json.loads(data_string)
|
| 7 |
+
print(data)
|
| 8 |
classifier = pipeline('zero-shot-classification', model='Xenova/mobilebert-uncased-mnli')
|
| 9 |
|
| 10 |
results = classifier(data.sequence, candidate_labels=data.candidate_labels, hypothesis_template=data.hypothesis_template, multi_label=data.multi_label)
|
|
|
|
| 12 |
|
| 13 |
gradio_interface = gradio.Interface(
|
| 14 |
fn = zero_shot_classification,
|
| 15 |
+
inputs = gradio.Textbox(label="JSON Input"),
|
| 16 |
outputs = "json"
|
| 17 |
)
|
| 18 |
gradio_interface.launch()
|