added small UI status pane for computational resources monitoring
Browse files- S2FApp/app.py +3 -2
- S2FApp/requirements.txt +1 -0
- S2FApp/ui/components.py +34 -0
S2FApp/app.py
CHANGED
|
@@ -31,6 +31,7 @@ from ui.components import (
|
|
| 31 |
build_cell_vals,
|
| 32 |
render_result_display,
|
| 33 |
render_region_canvas,
|
|
|
|
| 34 |
ST_DIALOG,
|
| 35 |
HAS_DRAWABLE_CANVAS,
|
| 36 |
)
|
|
@@ -384,5 +385,5 @@ elif run and not has_image:
|
|
| 384 |
st.warning("Please upload an image or select an example.")
|
| 385 |
|
| 386 |
st.sidebar.divider()
|
| 387 |
-
|
| 388 |
-
st.sidebar.caption(CITATION)
|
|
|
|
| 31 |
build_cell_vals,
|
| 32 |
render_result_display,
|
| 33 |
render_region_canvas,
|
| 34 |
+
render_system_status,
|
| 35 |
ST_DIALOG,
|
| 36 |
HAS_DRAWABLE_CANVAS,
|
| 37 |
)
|
|
|
|
| 385 |
st.warning("Please upload an image or select an example.")
|
| 386 |
|
| 387 |
st.sidebar.divider()
|
| 388 |
+
render_system_status()
|
| 389 |
+
st.sidebar.caption("<br>If you find this software useful, please cite:<br>" + CITATION, unsafe_allow_html=True)
|
S2FApp/requirements.txt
CHANGED
|
@@ -12,3 +12,4 @@ Pillow>=9.0.0
|
|
| 12 |
plotly>=5.14.0
|
| 13 |
huggingface_hub>=0.20.0
|
| 14 |
reportlab>=4.0.0
|
|
|
|
|
|
| 12 |
plotly>=5.14.0
|
| 13 |
huggingface_hub>=0.20.0
|
| 14 |
reportlab>=4.0.0
|
| 15 |
+
psutil>=5.9.0
|
S2FApp/ui/components.py
CHANGED
|
@@ -33,10 +33,44 @@ try:
|
|
| 33 |
except (ImportError, AttributeError):
|
| 34 |
HAS_DRAWABLE_CANVAS = False
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
# Resolve st.dialog early to fix ordering bug (used in _render_result_display)
|
| 37 |
ST_DIALOG = getattr(st, "dialog", None) or getattr(st, "experimental_dialog", None)
|
| 38 |
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
# Distinct colors for each region (RGB - heatmap_rgb is RGB)
|
| 41 |
_REGION_COLORS = [
|
| 42 |
(255, 102, 0), # orange
|
|
|
|
| 33 |
except (ImportError, AttributeError):
|
| 34 |
HAS_DRAWABLE_CANVAS = False
|
| 35 |
|
| 36 |
+
try:
|
| 37 |
+
import psutil
|
| 38 |
+
HAS_PSUTIL = True
|
| 39 |
+
except ImportError:
|
| 40 |
+
HAS_PSUTIL = False
|
| 41 |
+
|
| 42 |
# Resolve st.dialog early to fix ordering bug (used in _render_result_display)
|
| 43 |
ST_DIALOG = getattr(st, "dialog", None) or getattr(st, "experimental_dialog", None)
|
| 44 |
|
| 45 |
|
| 46 |
+
def render_system_status():
|
| 47 |
+
"""Render a small live CPU/memory status panel in the sidebar."""
|
| 48 |
+
if not HAS_PSUTIL:
|
| 49 |
+
return
|
| 50 |
+
try:
|
| 51 |
+
cpu = psutil.cpu_percent(interval=0.1)
|
| 52 |
+
mem = psutil.virtual_memory()
|
| 53 |
+
mem_used_gb = mem.used / (1024**3)
|
| 54 |
+
mem_total_gb = mem.total / (1024**3)
|
| 55 |
+
mem_pct = mem.percent
|
| 56 |
+
st.sidebar.markdown(
|
| 57 |
+
f"""
|
| 58 |
+
<div style="
|
| 59 |
+
font-size: 0.8rem; margin-top: 0.5rem; padding: 6px 10px;
|
| 60 |
+
border-radius: 6px;
|
| 61 |
+
border: 1px solid rgba(148, 163, 184, 0.3);
|
| 62 |
+
background: rgba(148, 163, 184, 0.1);
|
| 63 |
+
color: inherit;
|
| 64 |
+
">
|
| 65 |
+
<strong>System</strong> CPU {cpu:.0f}% · Mem {mem_pct:.0f}% ({mem_used_gb:.1f}/{mem_total_gb:.1f} GB)
|
| 66 |
+
</div>
|
| 67 |
+
""",
|
| 68 |
+
unsafe_allow_html=True,
|
| 69 |
+
)
|
| 70 |
+
except Exception:
|
| 71 |
+
pass
|
| 72 |
+
|
| 73 |
+
|
| 74 |
# Distinct colors for each region (RGB - heatmap_rgb is RGB)
|
| 75 |
_REGION_COLORS = [
|
| 76 |
(255, 102, 0), # orange
|