RleToMask
Decode a COCO/uncompressed RLE payload back into a usable mask
- masks_rle
- masks
The other half of this pack's MaskToRle: take a run-length-encoded payload and turn it back into a real MASK you can composite with or inpaint against inside the graph. You'll reach for this whenever a mask arrives compressed - from an API caller who sent RLE instead of an image, or from this pack's own SAM auto-mask nodes, which speak RLE natively rather than raw masks.
The inputs and outputs that matter
masks_rle(MASK_RLE) - the encoded payload.rle_mode(enum:uncompressed_rledefault, orcoco_rle) - has to match how the data was actually encoded. There's no auto-detection.masks(MASK) - the decoded output.
One wrinkle worth knowing if you're chaining this after SamAutoMaskSEGS specifically: that node emits a type called RLE_SEGS - a JSON string bundling potentially many masks plus metadata - not a single MASK_RLE. You can't wire SamAutoMaskSEGS straight into this node. This combination is for a single-mask RLE payload - MaskToRle's output, or SamAutoMaskSEGSAdvanced's, which does emit masks_rle directly.
How to install it
Via ComfyUI Manager: search comfyui-easyapi-nodes, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/lldacing/comfyui-easyapi-nodes.git
cd comfyui-easyapi-nodes
pip install -r requirements.txt
Restart ComfyUI. No models needed for this node.
Common issues & troubleshooting
Mode mismatch is the main one. Get coco_rle versus uncompressed_rle wrong relative to how the payload was actually encoded and you'll get a nonsense mask rather than an obvious error - if a decoded mask looks like noise, check the mode before anything else.
Lossiness runs the other way too. Because RLE only ever stores a binary yes/no per pixel, decoding it back never recovers a soft edge that existed before it was encoded - that detail is already gone at encode time, not something this node fails to restore.
Where the payload actually comes from matters for how you wire this. If you're consuming RLE that a client sent you over your own API (rather than something generated inside this same ComfyUI graph), the practical question is just making sure whatever produced it on their end used the same RLE convention COCO/pycocotools expects for coco_rle - width/height and the byte-run format have to line up, or you'll decode successfully into a mask that's simply the wrong shape rather than getting an outright failure.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| masks_rle | MASK_RLE | — | |
| rle_mode | COMBO | uncompressed_rle | 2 options: uncompressed_rle, coco_rle |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| masks | MASK | — |