Spaces:
Runtime error
Runtime error
New model with json output
Browse files
app.py
CHANGED
|
@@ -5,7 +5,6 @@ os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
|
|
| 5 |
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
|
| 6 |
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification, TextClassificationPipeline
|
| 7 |
|
| 8 |
-
|
| 9 |
tokenizer = AutoTokenizer.from_pretrained("dipesh/Intent-Classification-Bert-Base-Cased")
|
| 10 |
|
| 11 |
model = TFAutoModelForSequenceClassification.from_pretrained("dipesh/Intent-Classification-Bert-Base-Cased")
|
|
@@ -25,9 +24,10 @@ def predict(input_text):
|
|
| 25 |
ans += "?"
|
| 26 |
ans = intent_classifier(input_text)
|
| 27 |
|
| 28 |
-
return ans[0]['label'],
|
|
|
|
| 29 |
|
| 30 |
|
| 31 |
-
iface = gr.Interface(fn=predict, inputs="text", outputs="
|
| 32 |
description="Classifier")
|
| 33 |
iface.launch()
|
|
|
|
| 5 |
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
|
| 6 |
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification, TextClassificationPipeline
|
| 7 |
|
|
|
|
| 8 |
tokenizer = AutoTokenizer.from_pretrained("dipesh/Intent-Classification-Bert-Base-Cased")
|
| 9 |
|
| 10 |
model = TFAutoModelForSequenceClassification.from_pretrained("dipesh/Intent-Classification-Bert-Base-Cased")
|
|
|
|
| 24 |
ans += "?"
|
| 25 |
ans = intent_classifier(input_text)
|
| 26 |
|
| 27 |
+
return {"class": ans[0]['label'],
|
| 28 |
+
"accuracy": ans[0]['score']}
|
| 29 |
|
| 30 |
|
| 31 |
+
iface = gr.Interface(fn=predict, inputs="text", outputs="json", title="Intent Classifier",
|
| 32 |
description="Classifier")
|
| 33 |
iface.launch()
|