{"record":{"id":"77e59abe53057b0c","repo":"Comfy-Org/ComfyUI","slug":"the-mask-is-empty-so-there-is-nothing-to-action","errorCode":null,"errorMessage":"The mask is empty, so there is nothing to {action}. Masks are binarized at 50%: areas painted at less than half opacity are ignored.","messagePattern":"The mask is empty, so there is nothing to (.+?)\\. Masks are binarized at 50%: areas painted at less than half opacity are ignored\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/nodes_bria.py","lineNumber":272,"sourceCode":"                visual_input_content_moderation=moderation.get(\"visual_input_moderation\", False),\n                visual_output_content_moderation=moderation.get(\"visual_output_moderation\", False),\n                seed=seed,\n            ),\n            response_model=BriaStatusResponse,\n        )\n        response = await poll_op(\n            cls,\n            ApiEndpoint(path=f\"/proxy/bria/v2/status/{response.request_id}\"),\n            status_extractor=lambda r: r.status,\n            response_model=BriaRemoveBackgroundResponse,\n        )\n        return IO.NodeOutput(await download_url_to_image_tensor(response.result.image_url))\n\n\ndef _mask_to_binary_image(mask: Input.Image, action: str) -> torch.Tensor:\n    binary = (mask > 0.5).float()\n    if not binary.any():\n        raise ValueError(\n            f\"The mask is empty, so there is nothing to {action}. Masks are binarized at 50%: \"\n            f\"areas painted at less than half opacity are ignored.\"\n        )\n    return convert_mask_to_image(binary)\n\n\ndef _validate_mask_aspect_ratio(image: Input.Image, mask: Input.Image) -> None:\n    ih, iw = image.shape[1], image.shape[2]\n    mh, mw = mask.shape[-2], mask.shape[-1]\n    if abs(iw * mh - ih * mw) > 0.01 * ih * mw:\n        raise ValueError(f\"Mask must have the same aspect ratio as the image: image is {iw}x{ih}, mask is {mw}x{mh}.\")\n\n\nclass BriaGenFill(IO.ComfyNode):\n\n    @classmethod\n    def define_schema(cls):\n        return IO.Schema(","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/nodes_bria.py#L254-L290","documentation":"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).","triggerScenarios":"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.","commonSituations":"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).","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)."],"exampleFix":"# before\nbinary = (mask > 0.5).float()  # all zeros -> error\n# after\nmask = torch.clamp(mask, 0, 1)\nif (mask > 0.5).any():\n    binary = (mask > 0.5).float()","handlingStrategy":"validation","validationCode":"if not (mask > 0.5).any():\n    raise UserError('Mask has no pixels above 50% opacity - repaint before running.')","typeGuard":"def mask_is_effective(mask: torch.Tensor) -> bool:\n    return bool((mask > 0.5).any().item())","tryCatchPattern":null,"preventionTips":["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."],"tags":["comfyui","bria","mask","validation","threshold"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}