PraneshJs commited on
Commit
9c8420e
·
verified ·
1 Parent(s): 8530d04

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from txtemo import predict
3
+
4
+ def analyze_text(text):
5
+ if not text.strip():
6
+ return "Please enter some text.", ""
7
+
8
+ label, score = predict(text)
9
+ return f"Prediction: {label}", f"Confidence Score: {score:.2f}"
10
+
11
+ # Gradio UI
12
+ with gr.Blocks(title="txtemo - Emotion & Sentiment Detector") as demo:
13
+ gr.Markdown(
14
+ """
15
+ # ✨ txtemo — Emotion & Sentiment Detection
16
+ Enter any text below to detect its emotion/sentiment using a quantized RoBERTa ONNX model.
17
+ """
18
+ )
19
+
20
+ with gr.Row():
21
+ input_text = gr.Textbox(
22
+ label="Enter Text",
23
+ placeholder="Type your sentence here...",
24
+ lines=3
25
+ )
26
+
27
+ with gr.Row():
28
+ analyze_btn = gr.Button("Analyze", variant="primary")
29
+
30
+ with gr.Row():
31
+ output_label = gr.Textbox(label="Prediction")
32
+ output_score = gr.Textbox(label="Confidence Score")
33
+
34
+ analyze_btn.click(analyze_text, inputs=input_text, outputs=[output_label, output_score])
35
+
36
+ demo.launch()