Spaces:
Sleeping
Sleeping
Commit
·
f272743
1
Parent(s):
d7f360c
all files
Browse files- .github/workflows/deploy-to-huggingface.yml +67 -0
- Picture3.png +3 -0
- app.py +760 -0
- best_bilstm_model.h5 +3 -0
- best_gru_model.h5 +3 -0
- logo2.png +3 -0
- tensorflow.png +3 -0
.github/workflows/deploy-to-huggingface.yml
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Deploy Streamlit App to Hugging Face Space
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
branches:
|
6 |
+
- master # Adjust to your main branch (could be 'main' or 'master')
|
7 |
+
|
8 |
+
jobs:
|
9 |
+
deploy:
|
10 |
+
runs-on: ubuntu-latest
|
11 |
+
|
12 |
+
steps:
|
13 |
+
# Checkout the repository
|
14 |
+
- name: Checkout repository
|
15 |
+
uses: actions/checkout@v3
|
16 |
+
with:
|
17 |
+
lfs: true
|
18 |
+
# Set up Git
|
19 |
+
- name: Set up Git
|
20 |
+
run: |
|
21 |
+
git config --global user.name "dani-ange"
|
22 |
+
git config --global user.email "[email protected]"
|
23 |
+
|
24 |
+
# Install Git LFS (Large File Storage)
|
25 |
+
- name: Set up Git LFS
|
26 |
+
run: |
|
27 |
+
sudo apt-get update
|
28 |
+
sudo apt-get install git-lfs
|
29 |
+
git lfs install
|
30 |
+
|
31 |
+
# Install dependencies (if needed)
|
32 |
+
- name: Install dependencies
|
33 |
+
run: |
|
34 |
+
pip install -r requirements.txt
|
35 |
+
|
36 |
+
# Set up Hugging Face authentication
|
37 |
+
- name: Set up Hugging Face auth
|
38 |
+
env:
|
39 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
40 |
+
run: |
|
41 |
+
huggingface-cli login --token $HF_TOKEN
|
42 |
+
|
43 |
+
# Add remote for Hugging Face Space repository
|
44 |
+
- name: Add Hugging Face remote
|
45 |
+
run: |
|
46 |
+
|
47 |
+
git remote add space https://user:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/${{ secrets.HF_SPACE_REPO }}
|
48 |
+
|
49 |
+
# Track and push large files with Git LFS
|
50 |
+
- name: Track files with Git LFS
|
51 |
+
run: |
|
52 |
+
git lfs track "*.png"
|
53 |
+
git lfs track "*.h5"
|
54 |
+
git add .gitattributes
|
55 |
+
|
56 |
+
# Stage and commit all changes
|
57 |
+
- name: Commit changes
|
58 |
+
run: |
|
59 |
+
git add .
|
60 |
+
git commit -m "Update Streamlit app and model files" || echo "No changes to commit"
|
61 |
+
- name: List LFS-tracked files
|
62 |
+
run: git lfs ls-files
|
63 |
+
|
64 |
+
# Push to Hugging Face Space
|
65 |
+
- name: Push to Hugging Face Space
|
66 |
+
run: |
|
67 |
+
git push space master --force
|
Picture3.png
ADDED
![]() |
Git LFS Details
|
app.py
ADDED
@@ -0,0 +1,760 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import yfinance as yf
|
3 |
+
from streamlit_modal import Modal
|
4 |
+
import streamlit.components.v1 as components
|
5 |
+
|
6 |
+
# Set the page layout
|
7 |
+
st.set_page_config(layout="wide")
|
8 |
+
|
9 |
+
import matplotlib.pyplot as plt
|
10 |
+
import numpy as np
|
11 |
+
import base64
|
12 |
+
import pandas as pd
|
13 |
+
import time
|
14 |
+
from keras.models import load_model
|
15 |
+
from sklearn.preprocessing import MinMaxScaler
|
16 |
+
|
17 |
+
|
18 |
+
if "framework" not in st.session_state:
|
19 |
+
st.session_state.framework = "gen"
|
20 |
+
# Initialize state
|
21 |
+
if "show_modal" not in st.session_state:
|
22 |
+
st.session_state.show_modal = False
|
23 |
+
if "show_overlay" not in st.session_state:
|
24 |
+
st.session_state.show_overlay = False
|
25 |
+
if "model" not in st.session_state:
|
26 |
+
st.session_state.model = "best_bilstm_model.h5"
|
27 |
+
|
28 |
+
|
29 |
+
# Loading model
|
30 |
+
@st.cache_resource
|
31 |
+
def load_lstm_model(path):
|
32 |
+
return load_model(path)
|
33 |
+
|
34 |
+
|
35 |
+
@st.cache_resource
|
36 |
+
def load_data():
|
37 |
+
data = yf.download("AMZN", period="4y", multi_level_index=False)
|
38 |
+
data.reset_index(inplace=True)
|
39 |
+
return data
|
40 |
+
|
41 |
+
|
42 |
+
#################################################################################################
|
43 |
+
|
44 |
+
|
45 |
+
def predict_future_prices(
|
46 |
+
df: pd.DataFrame, n_future_days: int, model_path: str = st.session_state.model
|
47 |
+
) -> tuple[plt.Figure, pd.DataFrame]:
|
48 |
+
# Ensure DataFrame is sorted and clean
|
49 |
+
df = df.sort_values("Date").dropna(subset=["Close"])
|
50 |
+
df = df.reset_index(drop=True)
|
51 |
+
|
52 |
+
# Scale data
|
53 |
+
scaler = MinMaxScaler()
|
54 |
+
prices = df["Close"].values.reshape(-1, 1)
|
55 |
+
scaled_prices = scaler.fit_transform(prices)
|
56 |
+
|
57 |
+
# Load model and get timesteps
|
58 |
+
model = load_lstm_model(model_path)
|
59 |
+
n_steps = model.input_shape[1]
|
60 |
+
|
61 |
+
# --- Calculate validation error (historical residuals) ---
|
62 |
+
X_hist, y_hist = [], []
|
63 |
+
for i in range(n_steps, len(scaled_prices)):
|
64 |
+
X_hist.append(scaled_prices[i - n_steps : i])
|
65 |
+
y_hist.append(scaled_prices[i])
|
66 |
+
X_hist = np.array(X_hist)
|
67 |
+
y_hist = np.array(y_hist)
|
68 |
+
|
69 |
+
# Predict historical values
|
70 |
+
hist_predictions = model.predict(X_hist, verbose=0)
|
71 |
+
|
72 |
+
# Calculate residuals (error)
|
73 |
+
hist_prices_rescaled = scaler.inverse_transform(y_hist.reshape(-1, 1)).flatten()
|
74 |
+
hist_preds_rescaled = scaler.inverse_transform(
|
75 |
+
hist_predictions.reshape(-1, 1)
|
76 |
+
).flatten()
|
77 |
+
residuals = hist_prices_rescaled - hist_preds_rescaled
|
78 |
+
error_std = np.std(residuals) # Key metric for confidence interval
|
79 |
+
|
80 |
+
# --- Predict future values ---
|
81 |
+
last_sequence = scaled_prices[-n_steps:]
|
82 |
+
predicted = []
|
83 |
+
current_sequence = last_sequence.copy()
|
84 |
+
|
85 |
+
for _ in range(n_future_days):
|
86 |
+
pred = model.predict(current_sequence.reshape(1, n_steps, 1), verbose=0)
|
87 |
+
predicted.append(pred[0, 0])
|
88 |
+
current_sequence = np.append(current_sequence[1:], [[pred[0, 0]]], axis=0)
|
89 |
+
|
90 |
+
# Rescale predictions
|
91 |
+
predicted_prices = scaler.inverse_transform(
|
92 |
+
np.array(predicted).reshape(-1, 1)
|
93 |
+
).flatten()
|
94 |
+
future_dates = pd.date_range(
|
95 |
+
df["Date"].iloc[-1] + pd.Timedelta(days=1), periods=n_future_days
|
96 |
+
)
|
97 |
+
prediction_df = pd.DataFrame(
|
98 |
+
{"Date": future_dates, "Predicted Price": predicted_prices}
|
99 |
+
)
|
100 |
+
|
101 |
+
# --- Plotting with confidence interval ---
|
102 |
+
plt.rcParams["font.family"] = "Times New Roman "
|
103 |
+
|
104 |
+
fig, ax = plt.subplots(figsize=(10, 6), facecolor="none")
|
105 |
+
ax.patch.set_alpha(0)
|
106 |
+
fig.patch.set_alpha(0)
|
107 |
+
|
108 |
+
# Historical data
|
109 |
+
ax.plot(df["Date"], df["Close"], label="Historical", color="cyan", linewidth=2)
|
110 |
+
|
111 |
+
# Confidence interval (expanding uncertainty)
|
112 |
+
days = np.arange(1, n_future_days + 1)
|
113 |
+
expanding_std = error_std * np.sqrt(days)
|
114 |
+
upper = predicted_prices + 1.96 * expanding_std # 95% CI
|
115 |
+
lower = predicted_prices - 1.96 * expanding_std
|
116 |
+
|
117 |
+
ax.fill_between(
|
118 |
+
prediction_df["Date"],
|
119 |
+
lower,
|
120 |
+
upper,
|
121 |
+
color="lightblue",
|
122 |
+
alpha=0.3,
|
123 |
+
label="95% Confidence Interval",
|
124 |
+
)
|
125 |
+
|
126 |
+
# Predicted points (magenta dots)
|
127 |
+
ax.plot(
|
128 |
+
prediction_df["Date"],
|
129 |
+
prediction_df["Predicted Price"],
|
130 |
+
label=f"Next {n_future_days} Days Forecast",
|
131 |
+
color="magenta",
|
132 |
+
linestyle="None",
|
133 |
+
marker=".",
|
134 |
+
markersize=5,
|
135 |
+
)
|
136 |
+
|
137 |
+
# ---- NEW: Trend line spanning historical + forecasted data ----
|
138 |
+
# Combine historical and predicted dates/prices
|
139 |
+
all_dates = np.concatenate([df["Date"].values, prediction_df["Date"].values])
|
140 |
+
all_prices = np.concatenate(
|
141 |
+
[df["Close"].values, prediction_df["Predicted Price"].values]
|
142 |
+
)
|
143 |
+
|
144 |
+
# Calculate rolling mean (smoothing)
|
145 |
+
window_size = 30 # Adjust based on your data frequency
|
146 |
+
trend_line = pd.Series(all_prices).rolling(window=window_size, min_periods=1).mean()
|
147 |
+
|
148 |
+
# Plot the trend line (blue dashed)
|
149 |
+
ax.plot(
|
150 |
+
all_dates,
|
151 |
+
trend_line,
|
152 |
+
color="blue",
|
153 |
+
linestyle="--",
|
154 |
+
linewidth=1.5,
|
155 |
+
label="Long-Term Trend",
|
156 |
+
)
|
157 |
+
|
158 |
+
# Style
|
159 |
+
ax.set_title(
|
160 |
+
f"📈 Stock Price Forecast ({st.session_state.model})",
|
161 |
+
fontsize=14,
|
162 |
+
fontweight="bold",
|
163 |
+
)
|
164 |
+
ax.set_xlabel("Date", fontsize=12)
|
165 |
+
ax.set_ylabel("Price", fontsize=12)
|
166 |
+
ax.legend(loc="upper left")
|
167 |
+
ax.grid(True, linestyle="--", alpha=0.6)
|
168 |
+
|
169 |
+
return fig, prediction_df
|
170 |
+
|
171 |
+
|
172 |
+
#####################################################################################################
|
173 |
+
|
174 |
+
# Function to load data
|
175 |
+
|
176 |
+
|
177 |
+
# Load the data
|
178 |
+
# data = load_data()
|
179 |
+
# import matplotlib.pyplot as plt
|
180 |
+
# Path to your logo image
|
181 |
+
encoded_logo = "tensorflow.png"
|
182 |
+
main_bg_ext = "png"
|
183 |
+
main_bg = "Picture3.png "
|
184 |
+
|
185 |
+
|
186 |
+
if st.session_state.framework == "lstm":
|
187 |
+
bg_color = "#FF5733" # For example, a warm red/orange
|
188 |
+
bg_color_iv = "orange" # For example, a warm red/orange
|
189 |
+
text_h1 = "BI-DIRECTIONAL"
|
190 |
+
text_i = "Long short term memory"
|
191 |
+
model = "TENSORFLOW"
|
192 |
+
st.session_state.model = "best_bilstm_model.h5"
|
193 |
+
if st.session_state.framework == "gru":
|
194 |
+
bg_color = "#FF5733" # For example, a warm red/orange
|
195 |
+
bg_color_iv = "orange" # For example, a warm red/orange
|
196 |
+
text_h1 = "GATED RECURRENT UNIT"
|
197 |
+
text_i = "Recurrent Neural Network"
|
198 |
+
model = "TENSORFLOW"
|
199 |
+
st.session_state.model = "best_gru_model.h5"
|
200 |
+
if st.session_state.framework == "gen":
|
201 |
+
bg_color = "#FF5733" # For example, a warm red/orange
|
202 |
+
bg_color_iv = "orange" # For example, a warm red/orange
|
203 |
+
text_h1 = "Amazon Stock Predictor"
|
204 |
+
text_i = "21 Days Ahead of the Market"
|
205 |
+
model = "TENSORFLOW"
|
206 |
+
st.markdown(
|
207 |
+
f"""
|
208 |
+
<style>
|
209 |
+
/* Container for logo and text */
|
210 |
+
/* Container for logo and text */
|
211 |
+
.logo-text-container {{
|
212 |
+
position: fixed;
|
213 |
+
top: 20px; /* Adjust vertical position */
|
214 |
+
left: 30px; /* Align with sidebar */
|
215 |
+
display: flex;
|
216 |
+
align-items: center;
|
217 |
+
gap: 25px;
|
218 |
+
width: 70%;
|
219 |
+
z-index:1000;
|
220 |
+
}}
|
221 |
+
|
222 |
+
/* Logo styling */
|
223 |
+
.logo-text-container img {{
|
224 |
+
width: 50px; /* Adjust logo size */
|
225 |
+
border-radius: 10px; /* Optional: round edges */
|
226 |
+
margin-left:-5px;
|
227 |
+
margin-top: -15px;
|
228 |
+
|
229 |
+
}}
|
230 |
+
|
231 |
+
/* Bold text styling */
|
232 |
+
.logo-text-container h1 {{
|
233 |
+
font-family: Nunito;
|
234 |
+
color: #0175C2;
|
235 |
+
font-size: 25px;
|
236 |
+
font-weight: bold;
|
237 |
+
margin-right :100px;
|
238 |
+
padding:0px;
|
239 |
+
top:0;
|
240 |
+
margin-top: -12px;
|
241 |
+
}}
|
242 |
+
.logo-text-container i{{
|
243 |
+
font-family: Nunito;
|
244 |
+
color: orange;
|
245 |
+
font-size: 15px;
|
246 |
+
margin-right :10px;
|
247 |
+
padding:0px;
|
248 |
+
margin-left:-18.5%;
|
249 |
+
margin-top:1%;
|
250 |
+
}}
|
251 |
+
|
252 |
+
/* Sidebar styling */
|
253 |
+
section[data-testid="stSidebar"][aria-expanded="true"] {{
|
254 |
+
margin-top: 100px !important; /* Space for the logo */
|
255 |
+
border-radius: 0 60px 0px 60px !important; /* Top-left and bottom-right corners */
|
256 |
+
width: 200px !important; /* Sidebar width */
|
257 |
+
background: none; /* No background */
|
258 |
+
color: white !important;
|
259 |
+
}}
|
260 |
+
|
261 |
+
header[data-testid="stHeader"] {{
|
262 |
+
background: transparent !important;
|
263 |
+
margin-right: 100px !important;
|
264 |
+
margin-top: 1px !important;
|
265 |
+
z-index: 1 !important;
|
266 |
+
|
267 |
+
color: blue; /* White text */
|
268 |
+
font-family: "Times New Roman " !important; /* Font */
|
269 |
+
font-size: 18px !important; /* Font size */
|
270 |
+
font-weight: bold !important; /* Bold text */
|
271 |
+
padding: 10px 20px; /* Padding for buttons */
|
272 |
+
border: none; /* Remove border */
|
273 |
+
border-radius: 35px; /* Rounded corners */
|
274 |
+
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2); /* Shadow effect */
|
275 |
+
transition: all 0.3s ease-in-out; /* Smooth transition */
|
276 |
+
display: flex;
|
277 |
+
align-items: center;
|
278 |
+
justify-content: center;
|
279 |
+
margin: 10px 0;
|
280 |
+
width:90%;
|
281 |
+
left:5.5%;
|
282 |
+
height:60px;
|
283 |
+
margin-top:70px;
|
284 |
+
backdrop-filter: blur(10px);
|
285 |
+
border: 2px solid rgba(255, 255, 255, 0.4); /* Light border */
|
286 |
+
|
287 |
+
}}
|
288 |
+
|
289 |
+
div[data-testid="stDecoration"] {{
|
290 |
+
background-image: none;
|
291 |
+
}}
|
292 |
+
|
293 |
+
div[data-testid="stApp"] {{
|
294 |
+
background: url(data:image/{main_bg_ext};base64,{base64.b64encode(open(main_bg, "rb").read()).decode()});
|
295 |
+
background-size: cover; /* Ensure the image covers the full page */
|
296 |
+
background-position: center;
|
297 |
+
background-repeat:no-repeat;
|
298 |
+
height: 98vh;
|
299 |
+
width: 99.3%;
|
300 |
+
border-radius: 20px !important;
|
301 |
+
margin-left: 5px;
|
302 |
+
margin-right: 20px;
|
303 |
+
margin-top: 10px;
|
304 |
+
overflow: hidden;
|
305 |
+
backdrop-filter: blur(10px); /* Glass effect */
|
306 |
+
-webkit-backdrop-filter: blur(10px);
|
307 |
+
border: 1px solid rgba(255, 255, 255, 0.2); /* Light border */
|
308 |
+
|
309 |
+
}}
|
310 |
+
|
311 |
+
div[data-testid="stSidebarNav"] {{
|
312 |
+
display: none;
|
313 |
+
}}
|
314 |
+
|
315 |
+
div[data-testid="stSlider"] {{
|
316 |
+
margin-top:45px;
|
317 |
+
}}
|
318 |
+
label[data-testid="stWidgetLabel"]{{
|
319 |
+
margin-left:20px !important;
|
320 |
+
}}
|
321 |
+
|
322 |
+
div[data-baseweb="slider"] {{
|
323 |
+
border-radius: 30px;
|
324 |
+
padding-right:40px;
|
325 |
+
z-index: 1;
|
326 |
+
/* Glass effect background */
|
327 |
+
backdrop-filter: blur(2px);
|
328 |
+
-webkit-backdrop-filter: blur(12px);
|
329 |
+
/* Shiny blue borders (left & right) */
|
330 |
+
border-top: 2px solid rgba(255, 255, 155, 0.4); /* Light border */
|
331 |
+
margin-left:13px;
|
332 |
+
border-bottom: 2px solid rgba(255, 255, 155, 0.4); /* Light border */
|
333 |
+
|
334 |
+
|
335 |
+
}}
|
336 |
+
div[data-baseweb="slider"] > :nth-child(1)> div {{
|
337 |
+
margin-left:20px !important;
|
338 |
+
margin-top:10px;
|
339 |
+
}}
|
340 |
+
div[data-testid="stSliderTickBarMin"]{{
|
341 |
+
background:none !important;
|
342 |
+
margin-left:20px !important;
|
343 |
+
font-size:12px;
|
344 |
+
margin-bottom:5px;
|
345 |
+
font-family: "Times New Roman " !important; /* Font */
|
346 |
+
}}
|
347 |
+
div[data-testid="stSliderTickBarMax"]{{
|
348 |
+
background:none !important;
|
349 |
+
font-size:12px;
|
350 |
+
margin-bottom:5px;
|
351 |
+
|
352 |
+
font-family: "Times New Roman " !important; /* Font */
|
353 |
+
}}
|
354 |
+
div[data-testid="stSliderThumbValue"]{{
|
355 |
+
font-size:12px;
|
356 |
+
font-family: "Times New Roman " !important; /* Font */
|
357 |
+
|
358 |
+
}}
|
359 |
+
div[data-testid="stProgress"]{{
|
360 |
+
margin-right:25px;
|
361 |
+
margin-top:-70px;
|
362 |
+
height:10px !important;
|
363 |
+
|
364 |
+
}}
|
365 |
+
[class*="st-key-content-container-3"] {{
|
366 |
+
margin-top: 80px; /* Adjust top margin */
|
367 |
+
marging-left:50px !important;
|
368 |
+
color:orange;
|
369 |
+
|
370 |
+
}}
|
371 |
+
|
372 |
+
/* Button row styling */
|
373 |
+
.button-row {{
|
374 |
+
display: flex;
|
375 |
+
justify-content: flex-start;
|
376 |
+
gap: 20px;
|
377 |
+
margin-bottom: 20px;
|
378 |
+
}}
|
379 |
+
|
380 |
+
|
381 |
+
|
382 |
+
.custom-button:hover {{
|
383 |
+
background-color: #0056b3;
|
384 |
+
}}
|
385 |
+
div.stButton > button p{{
|
386 |
+
color: orange !important;
|
387 |
+
font-weight:bold;
|
388 |
+
}}
|
389 |
+
div.stButton > button {{
|
390 |
+
background: rgba(255, 255, 255, 0.2);
|
391 |
+
color: orange !important; /* White text */
|
392 |
+
font-family: "Times New Roman " !important; /* Font */
|
393 |
+
font-size: 18px !important; /* Font size */
|
394 |
+
font-weight: bold !important; /* Bold text */
|
395 |
+
padding: 10px 20px; /* Padding for buttons */
|
396 |
+
border: none; /* Remove border */
|
397 |
+
border-radius: 35px; /* Rounded corners */
|
398 |
+
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2); /* Shadow effect */
|
399 |
+
transition: all 0.3s ease-in-out; /* Smooth transition */
|
400 |
+
display: flex;
|
401 |
+
align-items: center;
|
402 |
+
justify-content: center;
|
403 |
+
margin: 10px 0;
|
404 |
+
width:160px;
|
405 |
+
height:50px;
|
406 |
+
margin-top:5px;
|
407 |
+
|
408 |
+
}}
|
409 |
+
|
410 |
+
/* Hover effect */
|
411 |
+
div.stButton > button:hover {{
|
412 |
+
background: rgba(255, 255, 255, 0.2);
|
413 |
+
box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.4); /* Enhanced shadow on hover */
|
414 |
+
transform: scale(1.05); /* Slightly enlarge button */
|
415 |
+
transform: scale(1.1); /* Slight zoom on hover */
|
416 |
+
box-shadow: 0px 4px 12px rgba(255, 255, 255, 0.4); /* Glow effect */
|
417 |
+
}}
|
418 |
+
|
419 |
+
div[data-testid="stMarkdownContainer"] p {{
|
420 |
+
font-family: "Times New Roman" !important; /* Elegant font for title */
|
421 |
+
color:black !important;
|
422 |
+
|
423 |
+
}}
|
424 |
+
.titles{{
|
425 |
+
margin-top:-50px !important;
|
426 |
+
margin-left:-40px;
|
427 |
+
font-family: "Times New Roman" !important;
|
428 |
+
|
429 |
+
}}
|
430 |
+
.header {{
|
431 |
+
display: flex;
|
432 |
+
align-items: center;
|
433 |
+
gap: 20px; /* Optional: adds space between image and text */
|
434 |
+
}}
|
435 |
+
.header img {{
|
436 |
+
height: 120px; /* Adjust as needed */
|
437 |
+
margin-top:-15px;
|
438 |
+
}}
|
439 |
+
/* Title styling */
|
440 |
+
.header h1{{
|
441 |
+
font-family: "Times New Roman" !important; /* Elegant font for title
|
442 |
+
font-size: 2.7rem;
|
443 |
+
font-weight: bold;
|
444 |
+
margin-left: 5px;
|
445 |
+
/* margin-top:-50px;*/
|
446 |
+
margin-bottom:30px;
|
447 |
+
padding: 0;
|
448 |
+
color: black; /* Neutral color for text */
|
449 |
+
}}
|
450 |
+
.titles .content{{
|
451 |
+
font-family: "Times New Roman" !important; /* Elegant font for title */
|
452 |
+
font-size: 1.2rem;
|
453 |
+
margin-left: 150px;
|
454 |
+
margin-bottom:1px;
|
455 |
+
padding: 0;
|
456 |
+
color:black; /* Neutral color for text */
|
457 |
+
}}
|
458 |
+
|
459 |
+
|
460 |
+
|
461 |
+
|
462 |
+
</style>
|
463 |
+
|
464 |
+
""",
|
465 |
+
unsafe_allow_html=True,
|
466 |
+
)
|
467 |
+
# Overlay container
|
468 |
+
st.markdown(
|
469 |
+
f"""
|
470 |
+
<style>
|
471 |
+
.logo-text-containers {{
|
472 |
+
position: absolute;
|
473 |
+
top: -60px;
|
474 |
+
right: 40px;
|
475 |
+
background-color: rgba(255, 255, 255, 0.9);
|
476 |
+
padding: 15px;
|
477 |
+
border-radius: 12px;
|
478 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
479 |
+
z-index: 10;
|
480 |
+
width:80vw;
|
481 |
+
height:620px;
|
482 |
+
}}
|
483 |
+
.logo-text-containers img {{
|
484 |
+
height: 40px;
|
485 |
+
right:0;
|
486 |
+
}}
|
487 |
+
.logo-text-containers h1 {{
|
488 |
+
display: inline;
|
489 |
+
font-size: 20px;
|
490 |
+
vertical-align: middle;
|
491 |
+
}}
|
492 |
+
.logo-text-containers i {{
|
493 |
+
display: block;
|
494 |
+
margin-top: 5px;
|
495 |
+
font-size: 14px;
|
496 |
+
color: #333;
|
497 |
+
}}
|
498 |
+
|
499 |
+
[class*="st-key-close-btn"] {{
|
500 |
+
top: 5px;
|
501 |
+
font-size: 20px;
|
502 |
+
font-weight: bold !important;
|
503 |
+
cursor: pointer;
|
504 |
+
position:absolute;
|
505 |
+
margin-left:1150px;
|
506 |
+
color:red !important;
|
507 |
+
z-index:1000;
|
508 |
+
}}
|
509 |
+
[class*="st-key-close-btn"]:hover {{
|
510 |
+
color: #f00;
|
511 |
+
}}
|
512 |
+
[class*="st-key-divider-col"] {{
|
513 |
+
border-left: 3px solid rgba(255, 255, 155, 0.5); /* Light border */
|
514 |
+
border-radius: 35px; /* Rounded corners */
|
515 |
+
margin-top:-15px;
|
516 |
+
margin-left:3px;
|
517 |
+
|
518 |
+
}}
|
519 |
+
[class*="st-key-col1"] {{
|
520 |
+
border-right: 3px solid rgba(255, 255, 155, 0.5); /* Light border */
|
521 |
+
border-radius: 35px; /* Rounded corners */
|
522 |
+
margin-left:20px;
|
523 |
+
margin-top:-15px;
|
524 |
+
|
525 |
+
}}
|
526 |
+
|
527 |
+
[class*="st-key-logo-text-containers"] {{
|
528 |
+
margin: 10px; /* Set a margin inside the container */
|
529 |
+
max-width: 100%;
|
530 |
+
overflow: hidden;
|
531 |
+
|
532 |
+
position: absolute;
|
533 |
+
top:-43px;
|
534 |
+
left:10px;
|
535 |
+
overflow: hidden;
|
536 |
+
background-color: tansparent;
|
537 |
+
padding: 15px;
|
538 |
+
border-radius: 30px;
|
539 |
+
padding-right:40px;
|
540 |
+
z-index: 1;
|
541 |
+
width:88vw;
|
542 |
+
height:660px;
|
543 |
+
/* Glass effect background */
|
544 |
+
background: rgba(255, 255, 255, 0.15);
|
545 |
+
backdrop-filter: blur(12px);
|
546 |
+
-webkit-backdrop-filter: blur(12px);
|
547 |
+
/* Shiny blue borders (left & right) */
|
548 |
+
border-left: 3px solid rgba(255, 255, 255, 0.9); /* Light border */
|
549 |
+
border-right: 3px solid rgba(255, 255, 255, 0.9); /* Light border */
|
550 |
+
|
551 |
+
|
552 |
+
}}
|
553 |
+
|
554 |
+
@media (max-width: 768px) {{
|
555 |
+
.logo-text-container h1 {{
|
556 |
+
font-size: 12px;
|
557 |
+
|
558 |
+
}}
|
559 |
+
.logo-text-container i {{
|
560 |
+
font-size: 10px;
|
561 |
+
ma
|
562 |
+
}}
|
563 |
+
|
564 |
+
|
565 |
+
.logo-text-container img {{
|
566 |
+
width: 30px; /* Adjust logo size */
|
567 |
+
border-radius: 10px; /* Optional: round edges */
|
568 |
+
margin-left:15px;
|
569 |
+
margin-top: -35px;
|
570 |
+
|
571 |
+
}}
|
572 |
+
|
573 |
+
}}
|
574 |
+
</style>
|
575 |
+
""",
|
576 |
+
unsafe_allow_html=True,
|
577 |
+
)
|
578 |
+
|
579 |
+
if st.session_state.show_overlay:
|
580 |
+
|
581 |
+
with st.container(key="logo-text-containers"):
|
582 |
+
if st.button("✕", key="close-btn"):
|
583 |
+
st.session_state.show_overlay = False
|
584 |
+
st.session_state.framework = "gen"
|
585 |
+
st.rerun()
|
586 |
+
with st.spinner("Downloading and processing the Data..."):
|
587 |
+
progress_bar = st.progress(0)
|
588 |
+
for i in range(1, 11):
|
589 |
+
time.sleep(0.6)
|
590 |
+
progress_bar.progress(i * 10)
|
591 |
+
with st.container(key="content"):
|
592 |
+
days = st.slider(
|
593 |
+
"Amazon Stock Insight: Predictive Analytics Over 21 Days",
|
594 |
+
1,
|
595 |
+
21,
|
596 |
+
7,
|
597 |
+
key="days_slider",
|
598 |
+
)
|
599 |
+
|
600 |
+
col1, col2 = st.columns([2.5, 3])
|
601 |
+
data = load_data()
|
602 |
+
if data is not None and not data.empty:
|
603 |
+
fig, future_data = predict_future_prices(
|
604 |
+
data, days+1, st.session_state.model
|
605 |
+
)
|
606 |
+
with col1:
|
607 |
+
with st.container(key="col1"):
|
608 |
+
future_data["Date"] = future_data["Date"].dt.strftime("%Y-%m-%d")
|
609 |
+
future_data = future_data[1:]
|
610 |
+
styled_html = (
|
611 |
+
future_data.style.set_table_attributes('class="glass-table"')
|
612 |
+
.set_table_styles(
|
613 |
+
[
|
614 |
+
{
|
615 |
+
"selector": "th",
|
616 |
+
"props": [
|
617 |
+
("padding", "12px"),
|
618 |
+
("color", "#000"),
|
619 |
+
(
|
620 |
+
"background-color",
|
621 |
+
"rgba(255, 255, 255, 0.15)",
|
622 |
+
),
|
623 |
+
],
|
624 |
+
},
|
625 |
+
{
|
626 |
+
"selector": "td",
|
627 |
+
"props": [
|
628 |
+
("padding", "10px"),
|
629 |
+
("color", "#000"),
|
630 |
+
("border-bottom", "1px solid rgba(0,0,0,0.1)"),
|
631 |
+
],
|
632 |
+
},
|
633 |
+
{
|
634 |
+
"selector": "table",
|
635 |
+
"props": [
|
636 |
+
("width", "100%"),
|
637 |
+
("border-collapse", "collapse"),
|
638 |
+
],
|
639 |
+
},
|
640 |
+
]
|
641 |
+
)
|
642 |
+
.to_html()
|
643 |
+
)
|
644 |
+
|
645 |
+
|
646 |
+
# Glassmorphism CSS + vertical scroll + black text
|
647 |
+
glass_css = """
|
648 |
+
<style>
|
649 |
+
/* Outer shell for glass effect & border radius */
|
650 |
+
.outer-glass-wrapper {
|
651 |
+
backdrop-filter: blur(10px);
|
652 |
+
-webkit-backdrop-filter: blur(10px);
|
653 |
+
background: rgba(255, 255, 255, 0.15);
|
654 |
+
border-radius: 20px;
|
655 |
+
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.2);
|
656 |
+
max-height: 600px;
|
657 |
+
max-width: 800px;
|
658 |
+
overflow: hidden;
|
659 |
+
margin-right: 15px;
|
660 |
+
margin-left:3px;
|
661 |
+
font-family: "Times New Roman " !important; /* Font */
|
662 |
+
|
663 |
+
font-size: 14px;
|
664 |
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
665 |
+
margin-bottom:30px;
|
666 |
+
|
667 |
+
}
|
668 |
+
|
669 |
+
/* Inner scrolling container */
|
670 |
+
.glass-container {
|
671 |
+
max-height: 410px;
|
672 |
+
overflow-y: auto;
|
673 |
+
padding: 16px 24px 16px 16px; /* right padding gives room for scrollbar */
|
674 |
+
}
|
675 |
+
|
676 |
+
/* Scrollbar styles */
|
677 |
+
.glass-container::-webkit-scrollbar {
|
678 |
+
width: 4px;
|
679 |
+
}
|
680 |
+
.glass-container::-webkit-scrollbar-track {
|
681 |
+
background: transparent;
|
682 |
+
}
|
683 |
+
.glass-container::-webkit-scrollbar-thumb {
|
684 |
+
background-color: rgba(0, 0, 0, 0.3);
|
685 |
+
border-radius: 10px;
|
686 |
+
}
|
687 |
+
.glass-container {
|
688 |
+
scrollbar-width: thin;
|
689 |
+
scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
|
690 |
+
}
|
691 |
+
|
692 |
+
/* Table styling */
|
693 |
+
.glass-table {
|
694 |
+
width: 100%;
|
695 |
+
}
|
696 |
+
.glass-table th, .glass-table td {
|
697 |
+
text-align: left;
|
698 |
+
white-space: nowrap;
|
699 |
+
color: #000;
|
700 |
+
}
|
701 |
+
</style>
|
702 |
+
"""
|
703 |
+
|
704 |
+
st.markdown(glass_css, unsafe_allow_html=True)
|
705 |
+
st.markdown(
|
706 |
+
f""" <div class="outer-glass-wrapper">
|
707 |
+
<div class="glass-container">
|
708 |
+
{styled_html}</div> </div>
|
709 |
+
""",
|
710 |
+
unsafe_allow_html=True,
|
711 |
+
)
|
712 |
+
|
713 |
+
with col2:
|
714 |
+
with st.container(key="divider-col"):
|
715 |
+
st.pyplot(fig)
|
716 |
+
|
717 |
+
else:
|
718 |
+
st.error("No data loaded. Please check your internet connection.")
|
719 |
+
# Show overlay if triggered
|
720 |
+
st.markdown(
|
721 |
+
f""" <div class="logo-text-container">
|
722 |
+
<img src="data:image/png;base64,{base64.b64encode(open("tensorflow.png","rb").read()).decode()}" alt="Uploaded Image">
|
723 |
+
<h1>{text_h1}<br></h1>
|
724 |
+
<i>{ text_i}</i>
|
725 |
+
</div>
|
726 |
+
|
727 |
+
""",
|
728 |
+
unsafe_allow_html=True,
|
729 |
+
)
|
730 |
+
|
731 |
+
|
732 |
+
st.markdown(
|
733 |
+
f""" <div class="titles">
|
734 |
+
<div class = "header">
|
735 |
+
<img src="data:image/png;base64,{base64.b64encode(open("logo2.png","rb").read()).decode()}" alt="Uploaded Image">
|
736 |
+
<h1></br>ACTIONS </br> TREND ANALYTICS</h1>
|
737 |
+
</div>
|
738 |
+
<div class="content">
|
739 |
+
A deep learning-powered tool that analyzes Amazon's stock trends.<br>
|
740 |
+
the models(BI-Direcional Lstm and GRU) predicts future market<br> actions based on past trends,
|
741 |
+
providing a confidence score to <br> help users interpret the data more accurately and take timely actions.
|
742 |
+
</div>
|
743 |
+
</div>
|
744 |
+
""",
|
745 |
+
unsafe_allow_html=True,
|
746 |
+
)
|
747 |
+
|
748 |
+
|
749 |
+
with st.container(key="content-container-3"):
|
750 |
+
col1, col2 = st.columns([1.5, 10.5])
|
751 |
+
with col1:
|
752 |
+
if st.button(" BIDIR-LSTM"):
|
753 |
+
st.session_state.framework = "lstm"
|
754 |
+
st.session_state.show_overlay = True
|
755 |
+
st.rerun()
|
756 |
+
with col2:
|
757 |
+
if st.button("GRU"):
|
758 |
+
st.session_state.framework = "gru"
|
759 |
+
st.session_state.show_overlay = True
|
760 |
+
st.rerun()
|
best_bilstm_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a75f0d928aac0e1fd053f6d4ba0d36591b36a7798a516806d2e5ec80b6865179
|
3 |
+
size 312736
|
best_gru_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cb8e3958412199cfd4134905ff76f5b1fff0cf4a61af3e048d9425b7e214291c
|
3 |
+
size 51376
|
logo2.png
ADDED
![]() |
Git LFS Details
|
tensorflow.png
ADDED
![]() |
Git LFS Details
|