ComfyUI Node

Set Dict Mask

Bundle a mask into a ComfyUI dict

By antrobot1234·Created 3 years ago·Updated about a year ago· 28
Set Dict Mask
  • MASK
  • DICT
  • DICT
key

Masks get passed around a lot in inpainting and compositing workflows, and the wire tends to run a long way - from wherever you built the mask to the sampler, the paste node, or the alpha-composite step that eventually uses it. Set Dict Mask lets you drop a mask into a DICT bundle so it rides across the graph on one shared wire with the rest of your values and gets fetched back out by name with a Get Dict.

It's the mask member of the antrobots dict family. The family is all about bundling: instead of a dedicated wire for every value, pack them into a single keyed container and route that around. It's the same graph-tidying move as rgthree's Context nodes, just an open bag where you name the slots - and this slot holds a mask.

When it's worth it

This pack leans into mask work - it ships Crop Image and Mask, Paste with Masks, and an Alpha Composite node, all of which juggle masks and images together. Bundling a mask lets it travel grouped with the image and the padding values it belongs with, so a compositing setup stays one clean package instead of four parallel wires. As always, for a short direct connection you don't need any of this; it pays off when the wire would otherwise stretch across the canvas or the mask has to reach more than one place.

There's no widget on this node - a mask isn't something you type - so the value is always an input connection. That makes Set Dict Mask an organizational tool: a labeled, typed port that pairs with a mask-typed Get Dict on the other end, rather than an inline convenience like the number and text variants offer.

How it works

A dict here is a Python dictionary on a custom DICT wire. Give the node a key and a MASK and it starts a fresh one-key bundle. Give it a key, a MASK, and an existing DICT, and it appends to that bundle and passes the whole thing forward. Chain them - output into the next DICT input - to build the bundle up.

The inputs and outputs that matter

  • key (string) - the name you'll fetch the mask by later, matched exactly by Get Dict.
  • MASK - the mask, wired in from a mask-producing node. No widget.
  • DICT (optional) - an existing bundle to append to; empty starts a new one.

Output is a single DICT, bound for the next Set Dict or a Get Dict.

Installing it

Install the whole pack. In ComfyUI Manager: Install Custom Nodes, search antrobots ComfyUI Nodepack, install, restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/antrobot1234/antrobots-comfyUI-nodepack

then restart ComfyUI. Pure Python, no models, no heavy dependencies - the install is painless.

Common issues

A mask-specific note: masks are picky about shape and channels across ComfyUI, and bundling one doesn't change that. Set Dict Mask stores whatever mask you give it as-is, so if the mask was the wrong size or inverted before it went into the bundle, it'll be exactly as wrong when the Get Dict pulls it back. Fix the mask upstream, then bundle it.

Otherwise it's the family's usual: keys are exact-string matches, so a spelling or capitalization mismatch between here and the Get Dict silently returns a default rather than throwing an error - check that first. The DICT type is antrobots-only and only comes back out through a Get Dict, never straight into a stock node. And because this is a small, quiet, one-person pack with almost no community footprint to search, the README's request to file a GitHub issue is the practical move when you hit a real bug.

Categoryantrobots-ComfyUI-nodepack/dicts/set

Inputs (3)

NameTypeDefaultDescription
keySTRING
MASKMASK
DICToptDICT

Outputs (1)

NameTypeDescription
DICTDICT