Update app.py
Browse files
app.py
CHANGED
|
@@ -3,8 +3,28 @@ import transformers
|
|
| 3 |
from transformers import pipeline
|
| 4 |
import re
|
| 5 |
|
| 6 |
-
#
|
| 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 |
-
#
|
| 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)
|
|
|