Spaces:
Running on Zero
Running on Zero
status shows CPU + GPU time breakdown
Browse files
app.py
CHANGED
|
@@ -915,8 +915,9 @@ def process_video(video_path, resolution, despill_val, mask_mode,
|
|
| 915 |
np.save(os.path.join(precompute_dir, f"mask_{frame_count:05d}.npy"), mask)
|
| 916 |
frame_count += 1
|
| 917 |
cap.release()
|
|
|
|
| 918 |
logger.info("[Phase 0] %d frames (%s screen) in %.1fs (needs_birefnet=%s)",
|
| 919 |
-
frame_count, detected_color,
|
| 920 |
|
| 921 |
logger.info("[Phase 1] Starting GPU phase")
|
| 922 |
t0 = time.time()
|
|
@@ -924,7 +925,8 @@ def process_video(video_path, resolution, despill_val, mask_mode,
|
|
| 924 |
auto_despeckle, despeckle_size, progress,
|
| 925 |
precompute_dir=precompute_dir, precompute_count=frame_count,
|
| 926 |
screen_color=detected_color)
|
| 927 |
-
|
|
|
|
| 928 |
|
| 929 |
tmpdir = data["tmpdir"]
|
| 930 |
w, h, fps = data["w"], data["h"], data["fps"]
|
|
@@ -964,11 +966,12 @@ def process_video(video_path, resolution, despill_val, mask_mode,
|
|
| 964 |
avg = np.mean(frame_times) if frame_times else 0
|
| 965 |
engine = "PyTorch GPU" if use_gpu else "ONNX CPU"
|
| 966 |
wall = time.time() - t_total
|
|
|
|
| 967 |
status = (f"Processed {n} frames ({w}x{h}) at {resolution}px | "
|
| 968 |
f"{avg:.2f}s/frame | {engine}" +
|
| 969 |
(f" batch={batch_size}" if use_gpu else "") +
|
| 970 |
-
f" | {wall:.0f}s total"
|
| 971 |
-
|
| 972 |
|
| 973 |
return (
|
| 974 |
comp_video if os.path.exists(comp_video) else None,
|
|
|
|
| 915 |
np.save(os.path.join(precompute_dir, f"mask_{frame_count:05d}.npy"), mask)
|
| 916 |
frame_count += 1
|
| 917 |
cap.release()
|
| 918 |
+
t_cpu = time.time() - t_mask
|
| 919 |
logger.info("[Phase 0] %d frames (%s screen) in %.1fs (needs_birefnet=%s)",
|
| 920 |
+
frame_count, detected_color, t_cpu, needs_birefnet)
|
| 921 |
|
| 922 |
logger.info("[Phase 1] Starting GPU phase")
|
| 923 |
t0 = time.time()
|
|
|
|
| 925 |
auto_despeckle, despeckle_size, progress,
|
| 926 |
precompute_dir=precompute_dir, precompute_count=frame_count,
|
| 927 |
screen_color=detected_color)
|
| 928 |
+
t_gpu = time.time() - t0
|
| 929 |
+
logger.info("[process_video] GPU phase done in %.1fs", t_gpu)
|
| 930 |
|
| 931 |
tmpdir = data["tmpdir"]
|
| 932 |
w, h, fps = data["w"], data["h"], data["fps"]
|
|
|
|
| 966 |
avg = np.mean(frame_times) if frame_times else 0
|
| 967 |
engine = "PyTorch GPU" if use_gpu else "ONNX CPU"
|
| 968 |
wall = time.time() - t_total
|
| 969 |
+
sc = data.get('screen_color', 'green')
|
| 970 |
status = (f"Processed {n} frames ({w}x{h}) at {resolution}px | "
|
| 971 |
f"{avg:.2f}s/frame | {engine}" +
|
| 972 |
(f" batch={batch_size}" if use_gpu else "") +
|
| 973 |
+
f" | {t_cpu:.0f}s CPU + {t_gpu:.0f}s GPU = {wall:.0f}s total" +
|
| 974 |
+
(f" | {sc} screen" if sc != "green" else ""))
|
| 975 |
|
| 976 |
return (
|
| 977 |
comp_video if os.path.exists(comp_video) else None,
|