omarhany commited on
Commit
cb87793
·
verified ·
1 Parent(s): 81a3fda

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +35 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ sentiment_pipeline = pipeline("sentiment-analysis")
5
+
6
+ def predict_sentiment(text):
7
+ result = sentiment_pipeline(text)[0]
8
+ return f"{result['label']}"
9
+
10
+ with gr.Blocks(theme=gr.themes.Soft()) as interface:
11
+ gr.Markdown(
12
+ """
13
+ <h1 style='text-align: center;'>Sentiment Analysis App</h1>
14
+ <p style='text-align: center;'>Analyze the sentiment of any review or short text. The model will classify it as <strong>Positive</strong> or <strong>Negative</strong>.</p>
15
+ """,
16
+ )
17
+
18
+ with gr.Row():
19
+ with gr.Column():
20
+ input_text = gr.Textbox(
21
+ label="Enter your text",
22
+ placeholder="Type your review here...",
23
+ lines=4
24
+ )
25
+ submit_btn = gr.Button("Analyze")
26
+
27
+ with gr.Column():
28
+ output_label = gr.Textbox(
29
+ label="Prediction",
30
+ interactive=False
31
+ )
32
+
33
+ submit_btn.click(predict_sentiment, inputs=input_text, outputs=output_label)
34
+
35
+ interface.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio==4.29.0
2
+ transformers==4.41.2
3
+ torch
4
+ numpy