Spaces:
Sleeping
Sleeping
removed reevaluation button
Browse files- pages/Model_Evaluation.py +9 -10
pages/Model_Evaluation.py
CHANGED
@@ -16,13 +16,16 @@ import streamlit as st
|
|
16 |
import matplotlib.pyplot as plt
|
17 |
from fpdf import FPDF
|
18 |
|
19 |
-
# ----
|
20 |
if 'stop_eval' not in st.session_state:
|
21 |
st.session_state.stop_eval = False
|
22 |
|
23 |
if 'evaluation_done' not in st.session_state:
|
24 |
st.session_state.evaluation_done = False
|
25 |
|
|
|
|
|
|
|
26 |
# ---- Streamlit Title ----
|
27 |
st.markdown("<h2 style='color: #2E86C1;'>π Model Evaluation</h2>", unsafe_allow_html=True)
|
28 |
|
@@ -106,7 +109,7 @@ def load_model():
|
|
106 |
model.eval()
|
107 |
return model
|
108 |
|
109 |
-
# ---- Main
|
110 |
csv_path = r"D:\\DR_Classification\\splits\\test_labels.csv"
|
111 |
model = load_model()
|
112 |
test_loader = load_test_data(csv_path)
|
@@ -117,9 +120,7 @@ with col1:
|
|
117 |
if st.button("π Start Evaluation"):
|
118 |
st.session_state.stop_eval = False
|
119 |
st.session_state.evaluation_done = False
|
120 |
-
|
121 |
-
else:
|
122 |
-
run_eval = False
|
123 |
|
124 |
with col2:
|
125 |
if st.button("π© Stop Evaluation"):
|
@@ -128,7 +129,8 @@ with col2:
|
|
128 |
if st.session_state.evaluation_done:
|
129 |
reevaluate_col, download_col = st.columns([1, 1])
|
130 |
|
131 |
-
|
|
|
132 |
st.markdown("### β±οΈ Evaluation Results")
|
133 |
|
134 |
start_time = time.time()
|
@@ -168,6 +170,7 @@ if run_eval or st.session_state.evaluation_done:
|
|
168 |
|
169 |
if not st.session_state.stop_eval:
|
170 |
st.session_state.evaluation_done = True
|
|
|
171 |
st.success(f"β
Evaluation completed in **{eval_time:.2f} seconds**")
|
172 |
|
173 |
report = classification_report(y_true, y_pred, target_names=class_names, output_dict=True)
|
@@ -241,7 +244,3 @@ if run_eval or st.session_state.evaluation_done:
|
|
241 |
reevaluate_col, download_col = st.columns([1, 1])
|
242 |
with download_col:
|
243 |
st.download_button("π Download Full Evaluation PDF", f, file_name="evaluation_report.pdf")
|
244 |
-
with reevaluate_col:
|
245 |
-
if st.button("π Re-evaluate"):
|
246 |
-
st.session_state.stop_eval = False
|
247 |
-
st.session_state.evaluation_done = False
|
|
|
16 |
import matplotlib.pyplot as plt
|
17 |
from fpdf import FPDF
|
18 |
|
19 |
+
# ---- Streamlit State Initialization ----
|
20 |
if 'stop_eval' not in st.session_state:
|
21 |
st.session_state.stop_eval = False
|
22 |
|
23 |
if 'evaluation_done' not in st.session_state:
|
24 |
st.session_state.evaluation_done = False
|
25 |
|
26 |
+
if 'trigger_eval' not in st.session_state:
|
27 |
+
st.session_state.trigger_eval = False
|
28 |
+
|
29 |
# ---- Streamlit Title ----
|
30 |
st.markdown("<h2 style='color: #2E86C1;'>π Model Evaluation</h2>", unsafe_allow_html=True)
|
31 |
|
|
|
109 |
model.eval()
|
110 |
return model
|
111 |
|
112 |
+
# ---- Main UI Buttons ----
|
113 |
csv_path = r"D:\\DR_Classification\\splits\\test_labels.csv"
|
114 |
model = load_model()
|
115 |
test_loader = load_test_data(csv_path)
|
|
|
120 |
if st.button("π Start Evaluation"):
|
121 |
st.session_state.stop_eval = False
|
122 |
st.session_state.evaluation_done = False
|
123 |
+
st.session_state.trigger_eval = True
|
|
|
|
|
124 |
|
125 |
with col2:
|
126 |
if st.button("π© Stop Evaluation"):
|
|
|
129 |
if st.session_state.evaluation_done:
|
130 |
reevaluate_col, download_col = st.columns([1, 1])
|
131 |
|
132 |
+
# ---- Evaluation Logic ----
|
133 |
+
if st.session_state.trigger_eval:
|
134 |
st.markdown("### β±οΈ Evaluation Results")
|
135 |
|
136 |
start_time = time.time()
|
|
|
170 |
|
171 |
if not st.session_state.stop_eval:
|
172 |
st.session_state.evaluation_done = True
|
173 |
+
st.session_state.trigger_eval = False # β
Reset the trigger
|
174 |
st.success(f"β
Evaluation completed in **{eval_time:.2f} seconds**")
|
175 |
|
176 |
report = classification_report(y_true, y_pred, target_names=class_names, output_dict=True)
|
|
|
244 |
reevaluate_col, download_col = st.columns([1, 1])
|
245 |
with download_col:
|
246 |
st.download_button("π Download Full Evaluation PDF", f, file_name="evaluation_report.pdf")
|
|
|
|
|
|
|
|