| import gradio as gr |
| from txtemo import predict |
|
|
| def analyze_text(text): |
| if not text.strip(): |
| return "Please enter some text.", "" |
| |
| label, score = predict(text) |
| return f"Prediction: {label}", f"Confidence Score: {score*100:.2f}" |
|
|
| |
| with gr.Blocks(title="txtemo - Emotion & Sentiment Detector") as demo: |
| gr.Markdown( |
| """ |
| # ✨ txtemo — Emotion & Sentiment Detection |
| Enter any text below to detect its emotion/sentiment using a quantized RoBERTa ONNX model. |
| """ |
| ) |
|
|
| with gr.Row(): |
| input_text = gr.Textbox( |
| label="Enter Text", |
| placeholder="Type your sentence here...", |
| lines=3 |
| ) |
|
|
| with gr.Row(): |
| analyze_btn = gr.Button("Analyze", variant="primary") |
|
|
| with gr.Row(): |
| output_label = gr.Textbox(label="Prediction") |
| output_score = gr.Textbox(label="Confidence Score") |
|
|
| analyze_btn.click(analyze_text, inputs=input_text, outputs=[output_label, output_score]) |
|
|
| demo.launch() |
|
|