File size: 677 Bytes
93643d5
040c521
d04fba3
e83c60c
d04fba3
6cf159b
 
47a0109
daac94f
47a0109
daac94f
9704577
abbb119
5071704
93643d5
 
daac94f
2d54881
93643d5
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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()