afridi15 commited on
Commit
e7e7088
·
verified ·
1 Parent(s): a2d2cb5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -2
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
- return clf(text)
8
 
9
- gr.Interface(fn=predict, inputs="text", outputs="text").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()