File size: 1,031 Bytes
9c8420e
 
 
 
 
 
 
 
dc82cb7
9c8420e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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}"

# Gradio UI
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()