MogensR commited on
Commit
8da2aa3
·
verified ·
1 Parent(s): d465483

Update ui.py

Browse files
Files changed (1) hide show
  1. ui.py +6 -11
ui.py CHANGED
@@ -14,6 +14,7 @@
14
  from datetime import datetime
15
  import time
16
  logger = logging.getLogger("Advanced Video Background Replacer")
 
17
  # --- UI Helpers ---
18
  def tail_file(path: str, lines: int = 400) -> str:
19
  """Read last N lines from a text file efficiently."""
@@ -25,6 +26,7 @@ def tail_file(path: str, lines: int = 400) -> str:
25
  return "".join(content[-lines:])
26
  except Exception as e:
27
  return f"(failed to read log: {e})"
 
28
  def read_file_bytes(path: str) -> bytes:
29
  """Read a file as bytes; return b'' if missing/error."""
30
  try:
@@ -34,6 +36,7 @@ def read_file_bytes(path: str) -> bytes:
34
  return f.read()
35
  except Exception:
36
  return b""
 
37
  # --- Render UI ---
38
  def render_ui(process_video_func):
39
  try:
@@ -41,16 +44,8 @@ def render_ui(process_video_func):
41
  with st.sidebar:
42
  st.subheader("System Status")
43
  st.markdown("**Log file:** `/tmp/app.log`")
44
- # Log level control
45
- log_level = st.selectbox(
46
- "Log Level",
47
- ["DEBUG", "INFO", "WARNING", "ERROR"],
48
- index=1, # Default: INFO
49
- key="log_level_select"
50
- )
51
- if log_level != st.session_state.get('log_level_name', 'INFO'):
52
- from streamlit_app import set_log_level
53
- set_log_level(log_level)
54
  if st.session_state.get('gpu_available', False):
55
  try:
56
  import torch
@@ -194,4 +189,4 @@ def render_ui(process_video_func):
194
  st.rerun()
195
  except Exception as e:
196
  logger.error(f"[UI] Render UI error: {e}", exc_info=True)
197
- st.error(f"UI rendering error: {str(e)}. Check logs for details.")
 
14
  from datetime import datetime
15
  import time
16
  logger = logging.getLogger("Advanced Video Background Replacer")
17
+
18
  # --- UI Helpers ---
19
  def tail_file(path: str, lines: int = 400) -> str:
20
  """Read last N lines from a text file efficiently."""
 
26
  return "".join(content[-lines:])
27
  except Exception as e:
28
  return f"(failed to read log: {e})"
29
+
30
  def read_file_bytes(path: str) -> bytes:
31
  """Read a file as bytes; return b'' if missing/error."""
32
  try:
 
36
  return f.read()
37
  except Exception:
38
  return b""
39
+
40
  # --- Render UI ---
41
  def render_ui(process_video_func):
42
  try:
 
44
  with st.sidebar:
45
  st.subheader("System Status")
46
  st.markdown("**Log file:** `/tmp/app.log`")
47
+ # (log-level selector has been REMOVED, handled in streamlit_app.py)
48
+
 
 
 
 
 
 
 
 
49
  if st.session_state.get('gpu_available', False):
50
  try:
51
  import torch
 
189
  st.rerun()
190
  except Exception as e:
191
  logger.error(f"[UI] Render UI error: {e}", exc_info=True)
192
+ st.error(f"UI rendering error: {str(e)}. Check logs for details.")