BoxOfColors Claude Opus 4.7 (1M context) commited on
Commit
567ee3a
·
1 Parent(s): e556888

fix: reject sub-32px frames in compute_crop_region

Browse files

The VACE / Wan2.1 VAE downsamples spatially by 32×, so each frame
dimension must be at least 32px. The existing crop logic floored the
target to a multiple of 32 then forced a min of 32 — but on a 30×30
frame, that produced a target larger than the frame, silently
overflowing downstream numpy slices in pipeline.composite.

Now compute_crop_region rejects frames smaller than MIN_FRAME_DIM=32
on either axis with a clean ValueError, surfacing the failure at the
point of detection instead of as a confusing slice-shape mismatch
later in the pipeline.

Reachable in practice via accidentally-tiny inputs (thumbnails uploaded
as videos, etc.).

Found by tests/test_callbacks.py round.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Files changed (1) hide show
  1. pipeline/crop.py +12 -0
pipeline/crop.py CHANGED
@@ -42,6 +42,13 @@ MAX_WATERMARK_AREA_FRACTION = 0.5
42
  # drawing so soft watermark edges don't bleed through after compositing.
43
  DEFAULT_DILATE_PX = 6
44
 
 
 
 
 
 
 
 
45
 
46
  # ---------------------------------------------------------------------------
47
  # Supported VACE / Wan2.1 resolutions
@@ -336,6 +343,11 @@ def compute_crop_region(
336
  ValueError
337
  If the watermark bbox is larger than the full frame (sanity check).
338
  """
 
 
 
 
 
339
  if watermark_bbox.width > frame_w or watermark_bbox.height > frame_h:
340
  raise ValueError(
341
  f"Watermark bbox {watermark_bbox} is larger than the frame "
 
42
  # drawing so soft watermark edges don't bleed through after compositing.
43
  DEFAULT_DILATE_PX = 6
44
 
45
+ # VACE / Wan2.1 VAE downsamples spatially by 32×, so each frame dimension
46
+ # must be at least 32px. Frames smaller than this are unprocessable; the
47
+ # floor-to-32 + max(32) logic in compute_crop_region would otherwise
48
+ # silently emit a target larger than the frame, overflowing downstream
49
+ # numpy slices in pipeline.composite.
50
+ MIN_FRAME_DIM = 32
51
+
52
 
53
  # ---------------------------------------------------------------------------
54
  # Supported VACE / Wan2.1 resolutions
 
343
  ValueError
344
  If the watermark bbox is larger than the full frame (sanity check).
345
  """
346
+ if frame_w < MIN_FRAME_DIM or frame_h < MIN_FRAME_DIM:
347
+ raise ValueError(
348
+ f"Frame is too small ({frame_w}×{frame_h}). "
349
+ f"Minimum supported dimension is {MIN_FRAME_DIM}px on each side."
350
+ )
351
  if watermark_bbox.width > frame_w or watermark_bbox.height > frame_h:
352
  raise ValueError(
353
  f"Watermark bbox {watermark_bbox} is larger than the frame "