Update ui.py
Browse files
ui.py
CHANGED
|
@@ -2,9 +2,7 @@
|
|
| 2 |
"""
|
| 3 |
Modern UI for Video Background Replacer (PRO)
|
| 4 |
- Clean, responsive Streamlit layout
|
| 5 |
-
-
|
| 6 |
-
- Supports: Color, Image upload, Stock image, AI Prompt background
|
| 7 |
-
- Log viewer, session state, robust error handling
|
| 8 |
"""
|
| 9 |
import streamlit as st
|
| 10 |
import os
|
|
@@ -164,11 +162,17 @@ def render_ui(process_video_func):
|
|
| 164 |
with col2:
|
| 165 |
background, bg_type = _render_background_settings()
|
| 166 |
st.header("3. Process Video")
|
|
|
|
| 167 |
can_process = (
|
| 168 |
uploaded_video is not None
|
| 169 |
and not st.session_state.get('processing', False)
|
| 170 |
and (background is not None)
|
| 171 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
if st.button("Process Video", disabled=not can_process, use_container_width=True):
|
| 173 |
try:
|
| 174 |
logger.info("Process Video button clicked")
|
|
@@ -177,13 +181,16 @@ def render_ui(process_video_func):
|
|
| 177 |
return
|
| 178 |
with st.spinner("Processing video..."):
|
| 179 |
# bg_type always lowercase for pipeline
|
| 180 |
-
success = process_video_func(uploaded_video, background, bg_type.lower())
|
| 181 |
if success:
|
|
|
|
| 182 |
st.success("Video processing complete!")
|
| 183 |
else:
|
|
|
|
| 184 |
st.error("Video processing failed. Check logs for details.")
|
| 185 |
except Exception as e:
|
| 186 |
logger.error(f"[UI] Process video error: {e}", exc_info=True)
|
|
|
|
| 187 |
st.error(f"Processing error: {str(e)}. Check logs for details.")
|
| 188 |
|
| 189 |
# --- Results Display ---
|
|
|
|
| 2 |
"""
|
| 3 |
Modern UI for Video Background Replacer (PRO)
|
| 4 |
- Clean, responsive Streamlit layout
|
| 5 |
+
- Shows live stage progress and all errors during processing
|
|
|
|
|
|
|
| 6 |
"""
|
| 7 |
import streamlit as st
|
| 8 |
import os
|
|
|
|
| 162 |
with col2:
|
| 163 |
background, bg_type = _render_background_settings()
|
| 164 |
st.header("3. Process Video")
|
| 165 |
+
status_box = st.empty() # <--- Status/progress area
|
| 166 |
can_process = (
|
| 167 |
uploaded_video is not None
|
| 168 |
and not st.session_state.get('processing', False)
|
| 169 |
and (background is not None)
|
| 170 |
)
|
| 171 |
+
|
| 172 |
+
def progress_callback(msg):
|
| 173 |
+
status_box.info(msg)
|
| 174 |
+
logger.info(f"[STAGE] {msg}")
|
| 175 |
+
|
| 176 |
if st.button("Process Video", disabled=not can_process, use_container_width=True):
|
| 177 |
try:
|
| 178 |
logger.info("Process Video button clicked")
|
|
|
|
| 181 |
return
|
| 182 |
with st.spinner("Processing video..."):
|
| 183 |
# bg_type always lowercase for pipeline
|
| 184 |
+
success = process_video_func(uploaded_video, background, bg_type.lower(), progress_callback)
|
| 185 |
if success:
|
| 186 |
+
status_box.success("✅ Video processing complete!")
|
| 187 |
st.success("Video processing complete!")
|
| 188 |
else:
|
| 189 |
+
status_box.error("❌ Video processing failed. Check logs for details.")
|
| 190 |
st.error("Video processing failed. Check logs for details.")
|
| 191 |
except Exception as e:
|
| 192 |
logger.error(f"[UI] Process video error: {e}", exc_info=True)
|
| 193 |
+
status_box.error(f"Processing error: {str(e)}. Check logs for details.")
|
| 194 |
st.error(f"Processing error: {str(e)}. Check logs for details.")
|
| 195 |
|
| 196 |
# --- Results Display ---
|