fathyshalab commited on
Commit
d9321e0
1 Parent(s): ba922c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -6,9 +6,11 @@ token = os.environ["token"]
6
  classifier = pipeline("zero-shot-classification",
7
  model="joeddav/xlm-roberta-large-xnli",use_auth_token=token)
8
 
9
- def classify(text):
10
- return classifier(text, candidate_labels)
 
 
11
 
12
- candidate_labels = ["wasser", "strom", "gas", "hausreinigung", "schoenheit", "wellness", "oeffentlichkeit", "oeffentlicher", "verkehr", "vermietung", "medizin", "gesundheit", "pflege", "reisen", "tourismus", "versicherungen", "recht"]
13
 
14
- gr.Interface(fn=classify, inputs="text", outputs="label").launch()
 
6
  classifier = pipeline("zero-shot-classification",
7
  model="joeddav/xlm-roberta-large-xnli",use_auth_token=token)
8
 
9
+ def classify(text, intent_labels):
10
+ res = classifier(text, intent_labels)
11
+ results = {k: v for k, v in zip(res["labels"], res["scores"])}
12
+ return results
13
 
14
+ # input is two text boxes, one for the text and one for the labels
15
 
16
+ gr.Interface(fn=classify, inputs=["textbox", "textbox"], outputs="label").launch()