Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| clf = pipeline("text-classification", model="afridi15/customer-support-intents") | |
| def predict(text): | |
| result = clf(text)[0] # {'label': 'LABEL_3', 'score': 0.85} | |
| return { | |
| "label": result["label"], | |
| "score": float(result["score"]) | |
| } | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# Intent Classifier API") | |
| input_box = gr.Textbox(label="Message") | |
| output_box = gr.JSON(label="Prediction") | |
| input_box.submit(predict, inputs=input_box, outputs=output_box) | |
| demo.queue(False) # π Disable queue mode β NO event_id, instant JSON | |
| demo.launch() | |