Adityaganesh commited on
Commit
8bc5288
Β·
verified Β·
1 Parent(s): 275dcf0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -4
app.py CHANGED
@@ -3,8 +3,28 @@ import transformers
3
  from transformers import pipeline
4
  import re
5
 
6
- # Title and Description
7
  st.set_page_config(page_title="Telugu Sentiment Analysis", layout="centered")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  st.title("πŸ“Š Telugu Sentiment Analysis")
9
  st.markdown("Analyze the sentiment (Positive, Negative, Neutral) of a given **Telugu** sentence using a fine-tuned BERT model.")
10
 
@@ -15,7 +35,7 @@ def load_pipeline():
15
 
16
  pipe = load_pipeline()
17
 
18
- # Optional: Text Preprocessing (basic cleaning)
19
  def preprocess_text(text):
20
  text = text.strip()
21
  text = re.sub(r"\s+", " ", text)
@@ -43,5 +63,4 @@ if st.button("πŸ” Analyze Sentiment"):
43
  sentiment = "😠 Negative"
44
  color = "red"
45
 
46
- st.markdown(f"### Prediction: <span style='color:{color}'>{sentiment}</span>", unsafe_allow_html=True)
47
- st.markdown(f"**Confidence:** {result['score']:.2f}")
 
3
  from transformers import pipeline
4
  import re
5
 
6
+ # Page Configuration
7
  st.set_page_config(page_title="Telugu Sentiment Analysis", layout="centered")
8
+
9
+ # Background Image via Custom CSS
10
+ def set_background(image_path):
11
+ st.markdown(
12
+ f"""
13
+ <style>
14
+ .stApp {{
15
+ background-image: url("{image_path}");
16
+ background-size: cover;
17
+ background-position: center;
18
+ background-repeat: no-repeat;
19
+ }}
20
+ </style>
21
+ """,
22
+ unsafe_allow_html=True
23
+ )
24
+
25
+ set_background("New3.jpg") # Make sure New3.jpg is in the same directory
26
+
27
+ # Title and Description
28
  st.title("πŸ“Š Telugu Sentiment Analysis")
29
  st.markdown("Analyze the sentiment (Positive, Negative, Neutral) of a given **Telugu** sentence using a fine-tuned BERT model.")
30
 
 
35
 
36
  pipe = load_pipeline()
37
 
38
+ # Text Preprocessing
39
  def preprocess_text(text):
40
  text = text.strip()
41
  text = re.sub(r"\s+", " ", text)
 
63
  sentiment = "😠 Negative"
64
  color = "red"
65
 
66
+ st.markdown(f"### Prediction: <span style='color:{color}'>{sentiment}</span>", unsafe_allow_html=True)