Comfy-Org/ComfyUI · error · ValueError
The mask is empty, so there is nothing to {action}. Masks ar
Error message
The mask is empty, so there is nothing to {action}. Masks are binarized at 50%: areas painted at less than half opacity are ignored. What it means
Bria mask inputs are binarized at 50% opacity ((mask > 0.5).float()) before upload. If no pixel survives that threshold the mask is empty, and the node raises instead of sending Bria a mask that selects nothing (which would no-op or error server-side).
Source
Thrown at comfy_api_nodes/nodes_bria.py:272
visual_input_content_moderation=moderation.get("visual_input_moderation", False),
visual_output_content_moderation=moderation.get("visual_output_moderation", False),
seed=seed,
),
response_model=BriaStatusResponse,
)
response = await poll_op(
cls,
ApiEndpoint(path=f"/proxy/bria/v2/status/{response.request_id}"),
status_extractor=lambda r: r.status,
response_model=BriaRemoveBackgroundResponse,
)
return IO.NodeOutput(await download_url_to_image_tensor(response.result.image_url))
def _mask_to_binary_image(mask: Input.Image, action: str) -> torch.Tensor:
binary = (mask > 0.5).float()
if not binary.any():
raise ValueError(
f"The mask is empty, so there is nothing to {action}. Masks are binarized at 50%: "
f"areas painted at less than half opacity are ignored."
)
return convert_mask_to_image(binary)
def _validate_mask_aspect_ratio(image: Input.Image, mask: Input.Image) -> None:
ih, iw = image.shape[1], image.shape[2]
mh, mw = mask.shape[-2], mask.shape[-1]
if abs(iw * mh - ih * mw) > 0.01 * ih * mw:
raise ValueError(f"Mask must have the same aspect ratio as the image: image is {iw}x{ih}, mask is {mw}x{mh}.")
class BriaGenFill(IO.ComfyNode):
@classmethod
def define_schema(cls):
return IO.Schema(View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Repaint the mask with full (or >50%) opacity in the affected areas.
- Check the mask tensor's actual min/max (e.g. print mask.min(), mask.max()) to confirm it is in [0,1] and exceeds 0.5 somewhere.
- If the mask is inverted, invert it before feeding the node (mask = 1.0 - mask).
Example fix
# before
binary = (mask > 0.5).float() # all zeros -> error
# after
mask = torch.clamp(mask, 0, 1)
if (mask > 0.5).any():
binary = (mask > 0.5).float() Defensive patterns
Strategy: validation
Validate before calling
if not (mask > 0.5).any():
raise UserError('Mask has no pixels above 50% opacity - repaint before running.') Type guard
def mask_is_effective(mask: torch.Tensor) -> bool:
return bool((mask > 0.5).any().item()) Prevention
- Paint masks at full opacity; check the mask editor's opacity setting.
- Verify mask tensor range is [0,1] and not inverted before Bria nodes.
When it happens
Trigger: Calling _mask_to_binary_image with a mask tensor whose every value is <= 0.5: fully black mask, mask painted with low-opacity brush strokes, or mask in [0,0.5] range after a bad conversion.
Common situations: User paints a mask at 30% opacity in the mask editor; upstream node outputs a normalized-but-inverted mask; mask tensor scaled to a range below 0.5 (e.g. 0-255 values divided wrong).
Related errors
- Mask must have the same aspect ratio as the image: image is
- One of prompt or structured_prompt is required to be non-emp
- Bria accepts a width-to-height ratio between {BRIA_MIN_RATIO
- Bria can upscale up to a maximum output dimension of {BRIA_M
- Provide either a background image or a background video, not
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/77e59abe53057b0c.
Report an issue: GitHub.