ui.py
CHANGED
|
@@ -288,39 +288,13 @@ def process_video_with_background_stoppable(
|
|
| 288 |
yield gr.update(visible=False), gr.update(visible=True), None, processing_status
|
| 289 |
|
| 290 |
try:
|
| 291 |
-
# Create a progress callback for real-time updates
|
| 292 |
-
def progress_callback(stage, message, progress_pct=None):
|
| 293 |
-
nonlocal processing_status
|
| 294 |
-
import time
|
| 295 |
-
timestamp = time.strftime("%H:%M:%S")
|
| 296 |
-
|
| 297 |
-
if stage == "sam2_loading":
|
| 298 |
-
processing_status = gpu_status + f"\n\n🚀 PROCESSING STARTED\n⏱️ [{timestamp}] Stage 1: Loading SAM2 model..."
|
| 299 |
-
elif stage == "sam2_processing":
|
| 300 |
-
processing_status = gpu_status + f"\n\n🚀 PROCESSING STARTED\n⏱️ [{timestamp}] Stage 1: SAM2 segmentation in progress..."
|
| 301 |
-
elif stage == "matanyone_loading":
|
| 302 |
-
processing_status = gpu_status + f"\n\n🚀 PROCESSING STARTED\n✅ Stage 1: SAM2 complete\n⏱️ [{timestamp}] Stage 2: Loading MatAnyone model..."
|
| 303 |
-
elif stage == "matanyone_processing":
|
| 304 |
-
processing_status = gpu_status + f"\n\n🚀 PROCESSING STARTED\n✅ Stage 1: SAM2 complete\n⏱️ [{timestamp}] Stage 2: MatAnyone video matting..."
|
| 305 |
-
elif stage == "compositing":
|
| 306 |
-
processing_status = gpu_status + f"\n\n🚀 PROCESSING STARTED\n✅ Stage 1: SAM2 complete\n✅ Stage 2: MatAnyone complete\n⏱️ [{timestamp}] Stage 3: Final compositing..."
|
| 307 |
-
|
| 308 |
-
if progress_pct:
|
| 309 |
-
processing_status += f" ({progress_pct}%)"
|
| 310 |
-
if message:
|
| 311 |
-
processing_status += f"\n💬 {message}"
|
| 312 |
-
|
| 313 |
-
# Note: We can't yield from callback, but we log for debugging
|
| 314 |
-
logger.info(f"Progress: {stage} - {message}")
|
| 315 |
-
|
| 316 |
out_path, diag = pipe.process(
|
| 317 |
video_path=video_path,
|
| 318 |
bg_image_path=bg_path,
|
| 319 |
point_x=None,
|
| 320 |
point_y=None,
|
| 321 |
auto_box=True,
|
| 322 |
-
work_dir=None
|
| 323 |
-
progress_callback=progress_callback # Pass callback if supported
|
| 324 |
)
|
| 325 |
logger.info(f"=== PIPELINE.PROCESS RETURNED ===")
|
| 326 |
logger.info(f"Pipeline completed: out_path={out_path}, diag={diag}")
|
|
|
|
| 288 |
yield gr.update(visible=False), gr.update(visible=True), None, processing_status
|
| 289 |
|
| 290 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
out_path, diag = pipe.process(
|
| 292 |
video_path=video_path,
|
| 293 |
bg_image_path=bg_path,
|
| 294 |
point_x=None,
|
| 295 |
point_y=None,
|
| 296 |
auto_box=True,
|
| 297 |
+
work_dir=None
|
|
|
|
| 298 |
)
|
| 299 |
logger.info(f"=== PIPELINE.PROCESS RETURNED ===")
|
| 300 |
logger.info(f"Pipeline completed: out_path={out_path}, diag={diag}")
|