Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,20 @@ from transformers import pipeline
|
|
| 4 |
clf = pipeline("text-classification", model="afridi15/customer-support-intents")
|
| 5 |
|
| 6 |
def predict(text):
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
clf = pipeline("text-classification", model="afridi15/customer-support-intents")
|
| 5 |
|
| 6 |
def predict(text):
|
| 7 |
+
result = clf(text)[0] # {'label': 'LABEL_3', 'score': 0.85}
|
| 8 |
|
| 9 |
+
return {
|
| 10 |
+
"label": result["label"],
|
| 11 |
+
"score": float(result["score"])
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
with gr.Blocks() as demo:
|
| 15 |
+
gr.Markdown("# Intent Classifier API")
|
| 16 |
+
|
| 17 |
+
input_box = gr.Textbox(label="Message")
|
| 18 |
+
output_box = gr.JSON(label="Prediction")
|
| 19 |
+
|
| 20 |
+
input_box.submit(predict, inputs=input_box, outputs=output_box)
|
| 21 |
+
|
| 22 |
+
demo.queue(False) # 🚀 Disable queue mode → NO event_id, instant JSON
|
| 23 |
+
demo.launch()
|