Spaces:
Sleeping
Sleeping
devjas1
commited on
Commit
·
614423c
1
Parent(s):
2c41fa3
(FEAT)(UI): Enhance results display with improved styling and session state management
Browse files- Standardize theme to dynamically adjust to system setting (light/dark)
- BUG FIXED: 'Clear Results' button now clears all results
app.py
CHANGED
|
@@ -146,6 +146,13 @@ div.stExpander > details > summary:hover::after {
|
|
| 146 |
content: "RESULTS";
|
| 147 |
background-color: #16A34A; /* Green is universal for success */
|
| 148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
}
|
| 150 |
.expander-advanced div[data-testid="stExpander"] summary::after {
|
| 151 |
content: "ADVANCED";
|
|
@@ -227,7 +234,7 @@ def init_session_state():
|
|
| 227 |
"status_type": "info",
|
| 228 |
"input_text": None,
|
| 229 |
"filename": None,
|
| 230 |
-
"input_source": None, # "upload" or "sample"
|
| 231 |
"sample_select": "-- Select Sample --",
|
| 232 |
"input_mode": "Upload File", # controls which pane is visible
|
| 233 |
"inference_run_once": False,
|
|
@@ -236,8 +243,12 @@ def init_session_state():
|
|
| 236 |
"uploader_version": 0,
|
| 237 |
"current_upload_key": "upload_txt_0",
|
| 238 |
"active_tab": "Details",
|
| 239 |
-
"batch_mode": False
|
| 240 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
for k, v in defaults.items():
|
| 242 |
st.session_state.setdefault(k, v)
|
| 243 |
|
|
@@ -597,7 +608,6 @@ def reset_ephemeral_state():
|
|
| 597 |
st.session_state["uploader_version"] += 1
|
| 598 |
st.session_state["current_upload_key"] = f"upload_txt_{st.session_state['uploader_version']}"
|
| 599 |
|
| 600 |
-
st.rerun()
|
| 601 |
|
| 602 |
# --- START: BUG 2 FIX (Callback Function) ---
|
| 603 |
|
|
@@ -611,11 +621,13 @@ def clear_batch_results():
|
|
| 611 |
st.rerun()
|
| 612 |
# --- END: BUG 2 FIX (Callback Function) ---
|
| 613 |
|
| 614 |
-
st.rerun()
|
| 615 |
|
| 616 |
-
|
|
|
|
|
|
|
| 617 |
|
| 618 |
|
|
|
|
| 619 |
def main():
|
| 620 |
init_session_state()
|
| 621 |
|
|
@@ -718,7 +730,8 @@ def main():
|
|
| 718 |
if uploaded_files:
|
| 719 |
# --- START: Bug 1 Fix ---
|
| 720 |
# Use a dictionary to keep only unique files based on name and size
|
| 721 |
-
unique_files = {(file.name, file.size)
|
|
|
|
| 722 |
unique_file_list = list(unique_files.values())
|
| 723 |
|
| 724 |
num_uploaded = len(uploaded_files)
|
|
@@ -999,11 +1012,11 @@ def main():
|
|
| 999 |
# This custom bullet bar logic remains as it is highly specific and valuable
|
| 1000 |
def create_bullet_bar(probability, width=20, predicted=False):
|
| 1001 |
filled_count = int(probability * width)
|
| 1002 |
-
bar = "
|
| 1003 |
-
"
|
| 1004 |
percentage = f"{probability:.1%}"
|
| 1005 |
pred_marker = "↩ Predicted" if predicted else ""
|
| 1006 |
-
return f"{bar} {percentage}
|
| 1007 |
|
| 1008 |
stable_prob, weathered_prob = probs[0], probs[1]
|
| 1009 |
is_stable_predicted, is_weathered_predicted = (
|
|
|
|
| 146 |
content: "RESULTS";
|
| 147 |
background-color: #16A34A; /* Green is universal for success */
|
| 148 |
|
| 149 |
+
}
|
| 150 |
+
div[data-testid="stExpander"] details {
|
| 151 |
+
content: "RESULTS";
|
| 152 |
+
background-color: var(--primary);
|
| 153 |
+
border-radius: 10px;
|
| 154 |
+
padding: 10px
|
| 155 |
+
|
| 156 |
}
|
| 157 |
.expander-advanced div[data-testid="stExpander"] summary::after {
|
| 158 |
content: "ADVANCED";
|
|
|
|
| 234 |
"status_type": "info",
|
| 235 |
"input_text": None,
|
| 236 |
"filename": None,
|
| 237 |
+
"input_source": None, # "upload", "batch" or "sample"
|
| 238 |
"sample_select": "-- Select Sample --",
|
| 239 |
"input_mode": "Upload File", # controls which pane is visible
|
| 240 |
"inference_run_once": False,
|
|
|
|
| 243 |
"uploader_version": 0,
|
| 244 |
"current_upload_key": "upload_txt_0",
|
| 245 |
"active_tab": "Details",
|
| 246 |
+
"batch_mode": False,
|
| 247 |
}
|
| 248 |
+
|
| 249 |
+
if 'uploader_key' not in st.session_state:
|
| 250 |
+
st.session_state.uploader_key = 0
|
| 251 |
+
|
| 252 |
for k, v in defaults.items():
|
| 253 |
st.session_state.setdefault(k, v)
|
| 254 |
|
|
|
|
| 608 |
st.session_state["uploader_version"] += 1
|
| 609 |
st.session_state["current_upload_key"] = f"upload_txt_{st.session_state['uploader_version']}"
|
| 610 |
|
|
|
|
| 611 |
|
| 612 |
# --- START: BUG 2 FIX (Callback Function) ---
|
| 613 |
|
|
|
|
| 621 |
st.rerun()
|
| 622 |
# --- END: BUG 2 FIX (Callback Function) ---
|
| 623 |
|
|
|
|
| 624 |
|
| 625 |
+
def reset_all():
|
| 626 |
+
# Increment the key to force the file uploader to re-render
|
| 627 |
+
st.session_state.uploader_key += 1
|
| 628 |
|
| 629 |
|
| 630 |
+
# Main app
|
| 631 |
def main():
|
| 632 |
init_session_state()
|
| 633 |
|
|
|
|
| 730 |
if uploaded_files:
|
| 731 |
# --- START: Bug 1 Fix ---
|
| 732 |
# Use a dictionary to keep only unique files based on name and size
|
| 733 |
+
unique_files = {(file.name, file.size)
|
| 734 |
+
: file for file in uploaded_files}
|
| 735 |
unique_file_list = list(unique_files.values())
|
| 736 |
|
| 737 |
num_uploaded = len(uploaded_files)
|
|
|
|
| 1012 |
# This custom bullet bar logic remains as it is highly specific and valuable
|
| 1013 |
def create_bullet_bar(probability, width=20, predicted=False):
|
| 1014 |
filled_count = int(probability * width)
|
| 1015 |
+
bar = "▤" * filled_count + \
|
| 1016 |
+
"▢" * (width - filled_count)
|
| 1017 |
percentage = f"{probability:.1%}"
|
| 1018 |
pred_marker = "↩ Predicted" if predicted else ""
|
| 1019 |
+
return f"{bar} {percentage} {pred_marker}"
|
| 1020 |
|
| 1021 |
stable_prob, weathered_prob = probs[0], probs[1]
|
| 1022 |
is_stable_predicted, is_weathered_predicted = (
|