Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,7 @@ import nltk
|
|
| 8 |
from nltk.tokenize import word_tokenize
|
| 9 |
from nltk.corpus import stopwords
|
| 10 |
from nltk.stem import WordNetLemmatizer
|
|
|
|
| 11 |
# Download necessary resources
|
| 12 |
nltk.download('punkt_tab')
|
| 13 |
nltk.download('stopwords')
|
|
@@ -16,8 +17,8 @@ nltk.download('wordnet')
|
|
| 16 |
import tensorflow
|
| 17 |
import keras
|
| 18 |
from keras.utils import pad_sequences
|
| 19 |
-
|
| 20 |
import pickle
|
|
|
|
| 21 |
|
| 22 |
# Streamlit UI
|
| 23 |
st.set_page_config(page_title="News Category Classifier", page_icon="📰", layout="centered")
|
|
@@ -29,15 +30,17 @@ def set_background(image_path):
|
|
| 29 |
bg_image_style = f"""
|
| 30 |
<style>
|
| 31 |
.stApp {{
|
| 32 |
-
background: url("data:image/png;base64,{encoded_img}")
|
| 33 |
background-size: cover;
|
|
|
|
|
|
|
| 34 |
}}
|
| 35 |
</style>
|
| 36 |
"""
|
| 37 |
st.markdown(bg_image_style, unsafe_allow_html=True)
|
| 38 |
|
| 39 |
# Update the image path
|
| 40 |
-
set_background("page/
|
| 41 |
|
| 42 |
# Initialize stopwords and lemmatizer
|
| 43 |
stop_words = set(stopwords.words('english')).union({"pm"})
|
|
@@ -156,4 +159,4 @@ if st.button("Analyze 🏷️"):
|
|
| 156 |
category = predict_category(user_input)
|
| 157 |
st.markdown(f"<div class='result-box'><span class='result-text'>🗂️ Predicted Category: <strong>{category}</strong></span></div>", unsafe_allow_html=True)
|
| 158 |
else:
|
| 159 |
-
st.warning("⚠️ Please enter some text to analyze.")
|
|
|
|
| 8 |
from nltk.tokenize import word_tokenize
|
| 9 |
from nltk.corpus import stopwords
|
| 10 |
from nltk.stem import WordNetLemmatizer
|
| 11 |
+
|
| 12 |
# Download necessary resources
|
| 13 |
nltk.download('punkt_tab')
|
| 14 |
nltk.download('stopwords')
|
|
|
|
| 17 |
import tensorflow
|
| 18 |
import keras
|
| 19 |
from keras.utils import pad_sequences
|
|
|
|
| 20 |
import pickle
|
| 21 |
+
import base64
|
| 22 |
|
| 23 |
# Streamlit UI
|
| 24 |
st.set_page_config(page_title="News Category Classifier", page_icon="📰", layout="centered")
|
|
|
|
| 30 |
bg_image_style = f"""
|
| 31 |
<style>
|
| 32 |
.stApp {{
|
| 33 |
+
background-image: url("data:image/png;base64,{encoded_img}");
|
| 34 |
background-size: cover;
|
| 35 |
+
background-repeat: no-repeat;
|
| 36 |
+
background-attachment: fixed;
|
| 37 |
}}
|
| 38 |
</style>
|
| 39 |
"""
|
| 40 |
st.markdown(bg_image_style, unsafe_allow_html=True)
|
| 41 |
|
| 42 |
# Update the image path
|
| 43 |
+
set_background("page/Images/bkg4.jpg") # Ensure the image is in the correct folder
|
| 44 |
|
| 45 |
# Initialize stopwords and lemmatizer
|
| 46 |
stop_words = set(stopwords.words('english')).union({"pm"})
|
|
|
|
| 159 |
category = predict_category(user_input)
|
| 160 |
st.markdown(f"<div class='result-box'><span class='result-text'>🗂️ Predicted Category: <strong>{category}</strong></span></div>", unsafe_allow_html=True)
|
| 161 |
else:
|
| 162 |
+
st.warning("⚠️ Please enter some text to analyze.")
|