Spaces:
Running on Zero
Running on Zero
cleanup: stale comments, dead import, redundant makedirs, fix batch size in UI
Browse files
app.py
CHANGED
|
@@ -544,9 +544,7 @@ def _gpu_decorator(fn):
|
|
| 544 |
def _gpu_phase(video_path, resolution, despill_val, mask_mode,
|
| 545 |
auto_despeckle, despeckle_size, progress=gr.Progress(),
|
| 546 |
precompute_dir=None, precompute_count=0):
|
| 547 |
-
"""ALL GPU work: load models, read video, generate masks, run inference.
|
| 548 |
-
Returns raw numpy results in RAM. No disk I/O.
|
| 549 |
-
"""
|
| 550 |
if video_path is None:
|
| 551 |
raise gr.Error("Please upload a video.")
|
| 552 |
|
|
@@ -712,8 +710,6 @@ def _gpu_phase(video_path, resolution, despill_val, mask_mode,
|
|
| 712 |
logger.info("[GPU phase] done: %d frames in %.1fs (%.2fs/fr)",
|
| 713 |
len(all_results), gpu_elapsed, gpu_elapsed / max(len(all_results), 1))
|
| 714 |
|
| 715 |
-
# FAST WRITE inside GPU: only comp (JPEG) + matte (PNG) + raw numpy.
|
| 716 |
-
# FG + Processed written AFTER GPU release (deferred).
|
| 717 |
from concurrent.futures import ThreadPoolExecutor
|
| 718 |
bg_lin = srgb_to_linear(create_checkerboard(w, h))
|
| 719 |
comp_dir = os.path.join(tmpdir, "Comp")
|
|
@@ -857,13 +853,8 @@ def process_video(video_path, resolution, despill_val, mask_mode,
|
|
| 857 |
fg_dir = os.path.join(tmpdir, "FG")
|
| 858 |
matte_dir = os.path.join(tmpdir, "Matte")
|
| 859 |
processed_dir = os.path.join(tmpdir, "Processed")
|
| 860 |
-
for d in [comp_dir, fg_dir, matte_dir, processed_dir]:
|
| 861 |
-
os.makedirs(d, exist_ok=True)
|
| 862 |
|
| 863 |
try:
|
| 864 |
-
from concurrent.futures import ThreadPoolExecutor
|
| 865 |
-
|
| 866 |
-
logger.info("[Phase 2] Frames written by GPU/CPU phase (comp+fg+matte)")
|
| 867 |
|
| 868 |
# Phase 3: stitch videos from written frames
|
| 869 |
logger.info("[Phase 3] Stitching videos")
|
|
@@ -933,7 +924,7 @@ with gr.Blocks(title="CorridorKey") as demo:
|
|
| 933 |
resolution = gr.Radio(
|
| 934 |
choices=["1024", "2048"], value="1024",
|
| 935 |
label="Processing Resolution",
|
| 936 |
-
info="1024 = fast (batch 32 on GPU), 2048 = max quality (batch
|
| 937 |
)
|
| 938 |
mask_mode = gr.Radio(
|
| 939 |
choices=["Hybrid (auto)", "AI (BiRefNet)", "Fast (classical)"],
|
|
|
|
| 544 |
def _gpu_phase(video_path, resolution, despill_val, mask_mode,
|
| 545 |
auto_despeckle, despeckle_size, progress=gr.Progress(),
|
| 546 |
precompute_dir=None, precompute_count=0):
|
| 547 |
+
"""ALL GPU work: load models, read video, generate masks, run inference, write frames."""
|
|
|
|
|
|
|
| 548 |
if video_path is None:
|
| 549 |
raise gr.Error("Please upload a video.")
|
| 550 |
|
|
|
|
| 710 |
logger.info("[GPU phase] done: %d frames in %.1fs (%.2fs/fr)",
|
| 711 |
len(all_results), gpu_elapsed, gpu_elapsed / max(len(all_results), 1))
|
| 712 |
|
|
|
|
|
|
|
| 713 |
from concurrent.futures import ThreadPoolExecutor
|
| 714 |
bg_lin = srgb_to_linear(create_checkerboard(w, h))
|
| 715 |
comp_dir = os.path.join(tmpdir, "Comp")
|
|
|
|
| 853 |
fg_dir = os.path.join(tmpdir, "FG")
|
| 854 |
matte_dir = os.path.join(tmpdir, "Matte")
|
| 855 |
processed_dir = os.path.join(tmpdir, "Processed")
|
|
|
|
|
|
|
| 856 |
|
| 857 |
try:
|
|
|
|
|
|
|
|
|
|
| 858 |
|
| 859 |
# Phase 3: stitch videos from written frames
|
| 860 |
logger.info("[Phase 3] Stitching videos")
|
|
|
|
| 924 |
resolution = gr.Radio(
|
| 925 |
choices=["1024", "2048"], value="1024",
|
| 926 |
label="Processing Resolution",
|
| 927 |
+
info="1024 = fast (batch 32 on GPU), 2048 = max quality (batch 16 on GPU)"
|
| 928 |
)
|
| 929 |
mask_mode = gr.Radio(
|
| 930 |
choices=["Hybrid (auto)", "AI (BiRefNet)", "Fast (classical)"],
|