NeonSamurai commited on
Commit
065ac26
·
verified ·
1 Parent(s): 442157d

Update News_app.py

Browse files
Files changed (1) hide show
  1. News_app.py +69 -46
News_app.py CHANGED
@@ -29,19 +29,18 @@ def set_background(local_image_path):
29
 
30
  bg_image_style = f"""
31
  <style>
32
- .stApp {{
33
- background-image: url("data:image/png;base64,{encoded_string}");
34
- background-size: cover;
35
- background-position: center center;
36
- background-repeat: no-repeat;
37
- background-attachment: fixed;
38
- }}
39
  </style>
40
  """
41
  st.markdown(bg_image_style, unsafe_allow_html=True)
42
 
43
  # Call this function with the path to your image
44
- set_background(r"Images/bkg3.jpg") # Replace with the actual image path
45
 
46
  # Initialize stopwords and lemmatizer
47
  stop_words = set(stopwords.words('english')).union({"pm"})
@@ -83,7 +82,7 @@ def predict_category(text):
83
  category_idx = np.argmax(prediction, axis=1)[0]
84
  return label_encoder.inverse_transform([category_idx])[0]
85
 
86
- # Enhanced UI
87
  st.markdown(
88
  """
89
  <style>
@@ -91,40 +90,28 @@ st.markdown(
91
  background-color: #f8f9fa;
92
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
93
  }
 
94
  .title {
95
- color: #ffffff; /* White text for contrast */
96
- font-size: 2.8em; /* Slightly larger font */
97
  text-align: center;
98
  font-weight: 700;
99
  margin-bottom: 15px;
100
- text-transform: uppercase; /* Makes it more prominent */
101
- text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.6); /* Adds a dark glow */
102
  padding: 10px;
103
- border: 3px solid rgba(255, 255, 255, 0.8); /* White border to highlight */
104
- border-radius: 10px;
105
- display: inline-block;
106
- background-color: rgba(0, 0, 0, 0.2); /* Slight dark tint for readability */
107
  }
108
-
109
  .subtitle {
 
 
110
  text-align: center;
111
- font-size: 1.3em; /* Slightly larger for readability */
112
- color: #fff; /* White text */
113
  font-weight: 600;
114
- margin-bottom: 25px;
115
- text-shadow: 1px 1px 6px rgba(0, 0, 0, 0.5); /* Dark shadow for better contrast */
116
  padding: 5px;
117
- border-radius: 5px;
118
- display: inline-block;
119
- }
120
-
121
- .text-area textarea {
122
- font-size: 16px;
123
- border: 2px solid #bdc3c7;
124
- border-radius: 8px;
125
- padding: 12px;
126
- background-color: #ecf0f1;
127
  }
 
128
  .classify-button {
129
  background-color: #3498db;
130
  color: white;
@@ -140,29 +127,65 @@ st.markdown(
140
  .classify-button:hover {
141
  background-color: #2980b9;
142
  }
 
143
  .result-box {
144
- background-color: rgba(255, 255, 255, 0.1); /* 20% transparency */
145
  padding: 20px;
146
- border-radius: 8px;
147
  text-align: center;
148
  margin-top: 30px;
149
- box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
150
- backdrop-filter: blur(10px); /* Optional: Adds a blur effect for better visibility */
151
- border: 2px solid rgba(255, 255, 255, 0.5); /* Optional: A subtle white border */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  }
153
  .result-text {
154
- font-size: 1.5em;
155
- color: #0c1e38; /* Darker color for better visibility */
156
- font-weight: 1000;
157
- text-shadow: 1px 1px 4px rgba(255, 255, 255, 0.7); /* Adds a subtle glow effect */
 
158
  }
 
159
  .warning-box {
160
- background-color: #ffcccc;
161
- padding: 15px;
162
- border-radius: 5px;
163
  text-align: center;
164
- color: #c0392b;
165
- margin-top: 20px;
 
 
 
 
 
 
166
  }
167
  </style>
168
  """,
 
29
 
30
  bg_image_style = f"""
31
  <style>
32
+ .stApp {{
33
+ background-image: url(data:image/{"png"};base64,{encoded_string});
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
  # Call this function with the path to your image
43
+ set_background(r"Images/bkg4.jpg") # Replace with the actual image path
44
 
45
  # Initialize stopwords and lemmatizer
46
  stop_words = set(stopwords.words('english')).union({"pm"})
 
82
  category_idx = np.argmax(prediction, axis=1)[0]
83
  return label_encoder.inverse_transform([category_idx])[0]
84
 
85
+ # UI
86
  st.markdown(
87
  """
88
  <style>
 
90
  background-color: #f8f9fa;
91
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
92
  }
93
+
94
  .title {
95
+ color: #ffffff;
96
+ font-size: 2.4em;
97
  text-align: center;
98
  font-weight: 700;
99
  margin-bottom: 15px;
100
+ text-transform: uppercase;
101
+ text-shadow: 2px 2px 8px rgba(0, 0, 0, 1.0);
102
  padding: 10px;
 
 
 
 
103
  }
104
+
105
  .subtitle {
106
+ color: #ffff;
107
+ font-size: 1.3em;
108
  text-align: center;
 
 
109
  font-weight: 600;
110
+ margin-bottom: 15px;
111
+ text-shadow: 1px 1px 6px rgba(0, 0, 0, 1.0);
112
  padding: 5px;
 
 
 
 
 
 
 
 
 
 
113
  }
114
+
115
  .classify-button {
116
  background-color: #3498db;
117
  color: white;
 
127
  .classify-button:hover {
128
  background-color: #2980b9;
129
  }
130
+
131
  .result-box {
132
+ background: linear-gradient(135deg, rgba(52, 152, 219, 1), rgba(231, 76, 60, 1)); /* Intense Blue-Red */
133
  padding: 20px;
134
+ border-radius: 10px;
135
  text-align: center;
136
  margin-top: 30px;
137
+ position: relative;
138
+ overflow: hidden;
139
+ border: 2px solid rgba(20, 30, 48, 0.9);
140
+ transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
141
+ }
142
+
143
+ /* Hover Effect */
144
+ .result-box:hover {
145
+ transform: scale(1.05);
146
+ box-shadow: 0px 15px 40px rgba(52, 152, 219, 1), 0px 15px 40px rgba(231, 76, 60, 1);
147
+ }
148
+
149
+ /* Light Reflection for Glossy Look */
150
+ .result-box::before {
151
+ content: "";
152
+ position: absolute;
153
+ top: -100%;
154
+ left: -100%;
155
+ width: 250%;
156
+ height: 250%;
157
+ background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 10%, rgba(255, 255, 255, 0) 70%);
158
+ opacity: 0.6;
159
+ transform: rotate(-25deg);
160
+ animation: shine 3s infinite linear;
161
+ }
162
+
163
+ /* Shimmer Animation */
164
+ @keyframes shine {
165
+ 0% { top: -150%; left: -150%; }
166
+ 100% { top: 150%; left: 150%; }
167
  }
168
  .result-text {
169
+ font-size: 1.8em;
170
+ color: #ffffff; /* Darker color for better visibility */
171
+ font-weight: 900;
172
+ text-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5);
173
+ animation: fadeIn 0.8s ease-in-out;
174
  }
175
+
176
  .warning-box {
177
+ background: linear-gradient(135deg, rgba(255, 77, 77, 0.8), rgba(255, 165, 0, 0.7)); /* Smooth red-orange gradient */
178
+ padding: 18px;
179
+ border-radius: 10px;
180
  text-align: center;
181
+ color: white;
182
+ font-weight: bold;
183
+ font-size: 1.2em;
184
+ text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.6);
185
+ margin-top: 25px;
186
+ border: 2px solid rgba(255, 77, 77, 0.9);
187
+ box-shadow: 0px 8px 15px rgba(255, 0, 0, 0.4);
188
+ transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
189
  }
190
  </style>
191
  """,