Skip to content

PersonMaskUltra V2: ValueError broadcasting (H,W,1,4) vs (H,W,4) when mask.numpy_view() returns 3D shape #606

Description

@CaptailTyler

The exact same code would run on my Zorin OS PC, but not Ubuntu 26.04. The fix was as per below:

Edit the file:
nano /home/ubuntu/comfy/ComfyUI/custom_nodes/comfyui_layerstyle/py/person_mask_ultra_v2.py

Find Line:
condition = np.stack((mask.numpy_view(),) * image_shape[-1], axis=-1) > confidence

Replace with:
mask_view = mask.numpy_view()
if mask_view.ndim == 3 and mask_view.shape[-1] == 1:
mask_view = mask_view.squeeze(-1)
condition = np.stack((mask_view,) * image_shape[-1], axis=-1) > confidence

it's inconsistent across environments (worked on one PC, failed on another with identical package versions) — pointing to a MediaPipe version/build quirk in how .numpy_view() shapes its output.

I hope this helps someone in the future.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions