Spaces:
Running
Running
spinner transformer
Browse files- streamlit_simulation/app.py +13 -1
streamlit_simulation/app.py
CHANGED
@@ -148,7 +148,8 @@ def init_session_state():
|
|
148 |
"true_timestamps": [],
|
149 |
"pred_timestamps": [],
|
150 |
"last_fig": None,
|
151 |
-
"valid_pos": 0
|
|
|
152 |
}
|
153 |
for key, value in defaults.items():
|
154 |
if key not in st.session_state:
|
@@ -379,6 +380,7 @@ if reset_button:
|
|
379 |
st.session_state.last_fig = None
|
380 |
st.session_state.is_running = False
|
381 |
st.session_state.valid_pos = 0
|
|
|
382 |
st.rerun()
|
383 |
|
384 |
# Auto-reset on critical parameter change while running
|
@@ -394,6 +396,7 @@ if st.session_state.is_running and (
|
|
394 |
st.session_state.true_timestamps = []
|
395 |
st.session_state.last_fig = None
|
396 |
st.session_state.valid_pos = 0
|
|
|
397 |
st.rerun()
|
398 |
|
399 |
# Track current selections for change detection
|
@@ -478,11 +481,16 @@ if model_choice == "LightGBM" and st.session_state.is_running:
|
|
478 |
|
479 |
# ============================== Transformer Simulation ==============================
|
480 |
|
|
|
|
|
481 |
if model_choice == "Transformer Model (moments)":
|
482 |
if st.session_state.is_running:
|
483 |
st.write("Simulation started (Transformer)...")
|
484 |
st.markdown('<div id="simulation"></div>', unsafe_allow_html=True)
|
485 |
|
|
|
|
|
|
|
486 |
plot_title, plot_container, x_axis_label, info_container = init_simulation_layout()
|
487 |
|
488 |
# Zugriff auf Modell, Dataset, Device
|
@@ -558,6 +566,10 @@ if model_choice == "Transformer Model (moments)":
|
|
558 |
)
|
559 |
if len(pred_vals) >= 2 and len(true_vals) >= 1:
|
560 |
render_simulation_view(current_time, current_pred, actual_val if i >= 1 else None, st.session_state.valid_pos / total_steps, fig)
|
|
|
|
|
|
|
|
|
561 |
|
562 |
plt.close(fig) # Speicher freigeben
|
563 |
|
|
|
148 |
"true_timestamps": [],
|
149 |
"pred_timestamps": [],
|
150 |
"last_fig": None,
|
151 |
+
"valid_pos": 0,
|
152 |
+
"first_plot_shown": False
|
153 |
}
|
154 |
for key, value in defaults.items():
|
155 |
if key not in st.session_state:
|
|
|
380 |
st.session_state.last_fig = None
|
381 |
st.session_state.is_running = False
|
382 |
st.session_state.valid_pos = 0
|
383 |
+
st.session_state.first_plot_shown = False
|
384 |
st.rerun()
|
385 |
|
386 |
# Auto-reset on critical parameter change while running
|
|
|
396 |
st.session_state.true_timestamps = []
|
397 |
st.session_state.last_fig = None
|
398 |
st.session_state.valid_pos = 0
|
399 |
+
st.session_state.first_plot_shown = False
|
400 |
st.rerun()
|
401 |
|
402 |
# Track current selections for change detection
|
|
|
481 |
|
482 |
# ============================== Transformer Simulation ==============================
|
483 |
|
484 |
+
spinner_placeholder = st.empty()
|
485 |
+
|
486 |
if model_choice == "Transformer Model (moments)":
|
487 |
if st.session_state.is_running:
|
488 |
st.write("Simulation started (Transformer)...")
|
489 |
st.markdown('<div id="simulation"></div>', unsafe_allow_html=True)
|
490 |
|
491 |
+
if not st.session_state.first_plot_shown:
|
492 |
+
spinner_placeholder.markdown("Running first prediction – please wait...")
|
493 |
+
|
494 |
plot_title, plot_container, x_axis_label, info_container = init_simulation_layout()
|
495 |
|
496 |
# Zugriff auf Modell, Dataset, Device
|
|
|
566 |
)
|
567 |
if len(pred_vals) >= 2 and len(true_vals) >= 1:
|
568 |
render_simulation_view(current_time, current_pred, actual_val if i >= 1 else None, st.session_state.valid_pos / total_steps, fig)
|
569 |
+
if not st.session_state.first_plot_shown:
|
570 |
+
spinner_placeholder.empty()
|
571 |
+
st.session_state.first_plot_shown = True
|
572 |
+
|
573 |
|
574 |
plt.close(fig) # Speicher freigeben
|
575 |
|