3v324v23 commited on
Commit
cb5e830
·
1 Parent(s): de8e4fb

final version

Browse files
Files changed (2) hide show
  1. .streamlit/config.toml +9 -0
  2. streamlit_simulation/app.py +10 -109
.streamlit/config.toml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ [theme]
2
+ base="light"
3
+ primaryColor="#FF4B4B"
4
+ backgroundColor="#f8f9fa"
5
+ textColor="#004080"
6
+ secondaryBackgroundColor="#e3e8ef"
7
+ font="sans serif"
8
+
9
+
streamlit_simulation/app.py CHANGED
@@ -10,11 +10,7 @@ import matplotlib.dates as mdates
10
  import warnings
11
  import torch
12
 
13
- from config_streamlit import (MODEL_PATH_LIGHTGBM, DATA_PATH, TRAIN_RATIO,
14
- TEXT_COLOR, HEADER_COLOR, ACCENT_COLOR,
15
- BUTTON_BG, BUTTON_HOVER_BG, BG_COLOR,
16
- INPUT_BG, PROGRESS_COLOR, PLOT_COLOR
17
- )
18
  from lightgbm_model.scripts.config_lightgbm import FEATURES
19
  from transformer_model.scripts.utils.informer_dataset_class import InformerDataset
20
  from transformer_model.scripts.training.load_basis_model import load_moment_model
@@ -33,95 +29,11 @@ st.set_page_config(page_title="Electricity Consumption Forecast", layout="wide")
33
  #CSS part
34
  st.markdown(f"""
35
  <style>
36
- body, .block-container {{
37
- background-color: {BG_COLOR} !important;
38
- }}
39
-
40
- html, body, [class*="css"] {{
41
- color: {TEXT_COLOR} !important;
42
- font-family: 'sans-serif';
43
- }}
44
-
45
- h1, h2, h3, h4, h5, h6 {{
46
- color: {HEADER_COLOR} !important;
47
- }}
48
-
49
  .stButton > button {{
50
- background-color: {BUTTON_BG};
51
- color: {TEXT_COLOR};
52
- border: 1px solid {ACCENT_COLOR};
53
- }}
54
-
55
- .stButton > button:hover {{
56
- background-color: {BUTTON_HOVER_BG};
57
  }}
58
 
59
- .stSelectbox div[data-baseweb="select"],
60
- .stDateInput input {{
61
- background-color: {INPUT_BG} !important;
62
- color: {TEXT_COLOR} !important;
63
- }}
64
-
65
- [data-testid="stMetricLabel"],
66
- [data-testid="stMetricValue"] {{
67
- color: {TEXT_COLOR} !important;
68
- }}
69
-
70
- .stMarkdown p {{
71
- color: {TEXT_COLOR} !important;
72
- }}
73
-
74
- .stDataFrame tbody tr td {{
75
- color: {TEXT_COLOR} !important;
76
- }}
77
-
78
- .stProgress > div > div {{
79
- background-color: {PROGRESS_COLOR} !important;
80
- }}
81
-
82
- /* Alle Label-Texte für Inputs/Sliders */
83
- label {{
84
- color: {TEXT_COLOR} !important;
85
- }}
86
-
87
- /* Text in selectbox-Optionsfeldern */
88
- .stSelectbox label, .stSelectbox div {{
89
- color: {TEXT_COLOR} !important;
90
- }}
91
-
92
- /* DateInput angleichen an Selectbox */
93
- .stDateInput input {{
94
- background-color: white !important;
95
- color: {TEXT_COLOR} !important;
96
- border: none !important;
97
- border-radius: 5px !important;
98
- }}
99
-
100
- body, html {{
101
- overflow-x: hidden !important;
102
- scrollbar-width: none; /* Firefox */
103
- }}
104
-
105
- /* Für Chrome, Safari, Edge */
106
- ::-webkit-scrollbar {{
107
- display: none;
108
- }}
109
-
110
- section[data-testid="stSidebar"] {{
111
- background-color: {INPUT_BG} !important;
112
- padding: 0rem !important;
113
- margin: 0rem !important;
114
- border: none !important;
115
- box-shadow: none !important;
116
- }}
117
-
118
- /* Sidebar: Hintergrund im inneren Container überschreiben */
119
- [data-testid="stSidebarUserContent"] > div[data-testid="block-container"] {{
120
- background-color: transparent !important;
121
- box-shadow: none !important;
122
- }}
123
-
124
- /* Entfernt auch den leeren Platz über der App */
125
  header[data-testid="stHeader"] {{
126
  display: none !important;
127
  height: 0px !important;
@@ -246,22 +158,18 @@ def create_prediction_plot(pred_timestamps, pred_vals, true_timestamps, true_val
246
  if true_vals:
247
  ax.plot(true_timestamps[-window_hours:], true_vals[-window_hours:], label="Actual", color="#0077B6")
248
 
249
- ax.set_ylabel("Consumption (MW)", fontsize=8, color=TEXT_COLOR)
250
  ax.legend(
251
  fontsize=8,
252
  loc="upper left",
253
- bbox_to_anchor=(0, 0.95),
254
- facecolor= INPUT_BG, # INPUT_BG
255
- edgecolor= ACCENT_COLOR, # ACCENT_COLOR
256
- labelcolor= TEXT_COLOR # TEXT_COLOR
257
  )
258
  ax.yaxis.grid(True, linestyle=':', linewidth=0.5, alpha=0.7)
259
  ax.set_ylim(y_min, y_max)
260
  ax.xaxis.set_major_locator(mdates.DayLocator(interval=1))
261
  ax.xaxis.set_major_formatter(mdates.DateFormatter("%m-%d"))
262
- ax.tick_params(axis="x", labelrotation=0, labelsize=5, colors=TEXT_COLOR)
263
- ax.tick_params(axis="y", labelsize=5, colors=TEXT_COLOR)
264
- #fig.patch.set_facecolor('#e6ecf0') # outer area
265
 
266
  for spine in ax.spines.values():
267
  spine.set_visible(False)
@@ -274,23 +182,16 @@ def render_simulation_view(timestamp, prediction, actual, progress, fig, paused=
274
  """Displays the simulation plot and metrics in the UI."""
275
  title = "Actual vs. Prediction (Paused)" if paused else "Actual vs. Prediction"
276
  plot_title.markdown(
277
- f"<div style='text-align: center; font-size: 20pt; font-weight: bold; color: {TEXT_COLOR}; margin-bottom: -0.7rem; margin-top: 0rem;'>"
278
  f"{title}</div>",
279
  unsafe_allow_html=True
280
  )
281
  plot_container.pyplot(fig)
282
 
283
- #st.markdown("<div style='margin-bottom: 0.5rem;'></div>", unsafe_allow_html=True)
284
- #x_axis_label.markdown(
285
- # f"<div style='text-align: center; font-size: 14pt; color: {TEXT_COLOR}; margin-top: -0.5rem;'>"
286
- # f"Time</div>",
287
- # unsafe_allow_html=True
288
- #)
289
-
290
  with info_container.container():
291
  #st.markdown("<div style='margin-top: 5rem;'></div>", unsafe_allow_html=True)
292
  st.markdown(
293
- f"<span style='font-size: 24px; font-weight: 600; color: {HEADER_COLOR} !important;'>Time: {timestamp}</span>",
294
  unsafe_allow_html=True
295
  )
296
 
@@ -312,7 +213,7 @@ def render_simulation_view(timestamp, prediction, actual, progress, fig, paused=
312
 
313
  st.divider()
314
  st.markdown(
315
- f"<span style='font-size: 24px; font-weight: 600; color: {HEADER_COLOR} !important;'>Interim Metrics</span>",
316
  unsafe_allow_html=True
317
  )
318
  st.metric("MAPE (so far)", f"{mape:.2f} %")
 
10
  import warnings
11
  import torch
12
 
13
+ from config_streamlit import (MODEL_PATH_LIGHTGBM, DATA_PATH, TRAIN_RATIO, PLOT_COLOR)
 
 
 
 
14
  from lightgbm_model.scripts.config_lightgbm import FEATURES
15
  from transformer_model.scripts.utils.informer_dataset_class import InformerDataset
16
  from transformer_model.scripts.training.load_basis_model import load_moment_model
 
29
  #CSS part
30
  st.markdown(f"""
31
  <style>
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  .stButton > button {{
33
+ background-color: {PLOT_COLOR};
 
 
 
 
 
 
34
  }}
35
 
36
+ /* Entfernt auch den leeren Platz über der App */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  header[data-testid="stHeader"] {{
38
  display: none !important;
39
  height: 0px !important;
 
158
  if true_vals:
159
  ax.plot(true_timestamps[-window_hours:], true_vals[-window_hours:], label="Actual", color="#0077B6")
160
 
161
+ ax.set_ylabel("Consumption (MW)", fontsize=8)
162
  ax.legend(
163
  fontsize=8,
164
  loc="upper left",
165
+ bbox_to_anchor=(0, 0.95)
 
 
 
166
  )
167
  ax.yaxis.grid(True, linestyle=':', linewidth=0.5, alpha=0.7)
168
  ax.set_ylim(y_min, y_max)
169
  ax.xaxis.set_major_locator(mdates.DayLocator(interval=1))
170
  ax.xaxis.set_major_formatter(mdates.DateFormatter("%m-%d"))
171
+ ax.tick_params(axis="x", labelrotation=0, labelsize=5)
172
+ ax.tick_params(axis="y", labelsize=5)
 
173
 
174
  for spine in ax.spines.values():
175
  spine.set_visible(False)
 
182
  """Displays the simulation plot and metrics in the UI."""
183
  title = "Actual vs. Prediction (Paused)" if paused else "Actual vs. Prediction"
184
  plot_title.markdown(
185
+ f"<div style='text-align: center; font-size: 20pt; font-weight: bold; margin-bottom: -0.7rem; margin-top: 0rem;'>"
186
  f"{title}</div>",
187
  unsafe_allow_html=True
188
  )
189
  plot_container.pyplot(fig)
190
 
 
 
 
 
 
 
 
191
  with info_container.container():
192
  #st.markdown("<div style='margin-top: 5rem;'></div>", unsafe_allow_html=True)
193
  st.markdown(
194
+ f"<span style='font-size: 24px; font-weight: 600;'>Time: {timestamp}</span>",
195
  unsafe_allow_html=True
196
  )
197
 
 
213
 
214
  st.divider()
215
  st.markdown(
216
+ f"<span style='font-size: 24px; font-weight: 600;'>Interim Metrics</span>",
217
  unsafe_allow_html=True
218
  )
219
  st.metric("MAPE (so far)", f"{mape:.2f} %")