MogensR commited on
Commit
6b106ac
·
1 Parent(s): e931565

Update ui_components.py

Browse files
Files changed (1) hide show
  1. ui_components.py +15 -3
ui_components.py CHANGED
@@ -38,7 +38,7 @@ def create_interface():
38
  def enhanced_process_video(
39
  video_path, bg_method, custom_img, prof_choice,
40
  use_two_stage, chroma_preset, quality_preset,
41
- is_processing_state, frame_progress_state, progress: gr.Progress = None
42
  ):
43
  """
44
  Handles video processing (start/stop) and live frame/fps reporting.
@@ -113,6 +113,17 @@ def progress_callback(pct, desc, current_frame=None, total_frames=None):
113
  is_processing_state = False
114
  return None, f"Error: {str(e)}", "Error during processing.", False, frame_progress_state
115
 
 
 
 
 
 
 
 
 
 
 
 
116
  # --- UI setup ---
117
  with gr.Blocks(
118
  title="BackgroundFX Pro",
@@ -207,8 +218,9 @@ def update_frame_fields(frame_progress):
207
  show_progress=True
208
  )
209
 
 
210
  load_models_btn.click(
211
- fn=lambda progress=gr.Progress(): load_models_with_validation(progress),
212
  outputs=[status_text],
213
  show_progress=True
214
  )
@@ -216,4 +228,4 @@ def update_frame_fields(frame_progress):
216
  return demo
217
 
218
  def create_ui():
219
- return create_interface()
 
38
  def enhanced_process_video(
39
  video_path, bg_method, custom_img, prof_choice,
40
  use_two_stage, chroma_preset, quality_preset,
41
+ is_processing_state, frame_progress_state, progress=gr.Progress()
42
  ):
43
  """
44
  Handles video processing (start/stop) and live frame/fps reporting.
 
113
  is_processing_state = False
114
  return None, f"Error: {str(e)}", "Error during processing.", False, frame_progress_state
115
 
116
+ def handle_model_loading(progress=gr.Progress()):
117
+ """
118
+ Wrapper function for model loading with proper progress handling
119
+ """
120
+ try:
121
+ # Call the model loading function with progress callback
122
+ result = load_models_with_validation(progress)
123
+ return result
124
+ except Exception as e:
125
+ return f"Model loading failed: {str(e)}"
126
+
127
  # --- UI setup ---
128
  with gr.Blocks(
129
  title="BackgroundFX Pro",
 
218
  show_progress=True
219
  )
220
 
221
+ # Fixed model loading button - let Gradio handle progress automatically
222
  load_models_btn.click(
223
+ fn=handle_model_loading,
224
  outputs=[status_text],
225
  show_progress=True
226
  )
 
228
  return demo
229
 
230
  def create_ui():
231
+ return create_interface()