From 94b2223109aab377eb00dfda5b6df868afc1b526 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 1 Feb 2026 12:54:19 +0530 Subject: [PATCH] Fix: Handle empty masks in get_mask_boxes to prevent crash --- wan/modules/animate/preprocess/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wan/modules/animate/preprocess/utils.py b/wan/modules/animate/preprocess/utils.py index 0513d21d..80085a7d 100644 --- a/wan/modules/animate/preprocess/utils.py +++ b/wan/modules/animate/preprocess/utils.py @@ -14,6 +14,13 @@ def get_mask_boxes(mask): """ y_coords, x_coords = np.nonzero(mask) + + # Handle empty mask: return full frame fallback to prevent crash + if len(x_coords) == 0 or len(y_coords) == 0: + h, w = mask.shape + # Return a valid full-frame bounding box + return np.array([0, 0, w-1, h-1]).astype(np.int32) + x_min = x_coords.min() x_max = x_coords.max() y_min = y_coords.min()