Lord-Raven
Trying to re-use pipeline.
6cf159b
raw
history blame
677 Bytes
import gradio
import json
from transformers import pipeline
from transformers import AutoTokenizer
classifier = pipeline(task='zero-shot-classification', model='typeform/distilbert-base-uncased-mnli')
def zero_shot_classification(data_string):
print(data_string)
data = json.loads(data_string)
print(data)
results = classifier(data['sequence'], candidate_labels=data['candidate_labels'], hypothesis_template=data['hypothesis_template'], multi_label=data['multi_label'])
return results
gradio_interface = gradio.Interface(
fn = zero_shot_classification,
inputs = gradio.Textbox(label="JSON Input"),
outputs = "text"
)
gradio_interface.launch()