Nodes/ComfyUI_agilly1989_motorway/CropMask_motorway_edition
ComfyUI Node

CropMask_motorway_edition

Crop a mask by x/y/width/height, routed through the Motorway

By agilly1989Β·Created 2 years agoΒ·Updated about a year agoΒ· 7
CropMask_motorway_edition
  • MOTORWAY πŸšŒπŸ’¨
  • MOTORWAY πŸšŒπŸ’¨
β—„INPUT_mask_keymaskβ–Ί
β—„x0β–Ί
β—„y0β–Ί
β—„width512β–Ί
β—„height512β–Ί
β—„OUTPUT_MASK_keyMASKβ–Ί

If you've ever needed to isolate one region of a mask - say, grab just the face region of a full-body segmentation mask so you can detail only that - you know the core CropMask node. Give it the mask and an x/y/width/height box and it returns just that rectangle. This _motorway_edition is that node rehosted on agilly1989's Motorway bus, so instead of a mask going in on a wire and coming out on a wire, the mask is already in the bus and you just tell the node which keys to use.

How it works

Mechanically it's the core CropMask from nodes.py - it crops the MASK tensor to the pixel box you specify and returns the cropped mask. The Motorway wrapper pulls the mask out of the bus by INPUT_mask_key, applies the crop with the four widget values, and stores the result under OUTPUT_MASK_key. That's the entire job. Where it gets genuinely handy in a Motorway workflow is when your pipeline already computed a mask (segmentation, bbox detection, inpainting prep) and parked it in the bus - you crop it here without ever routing the tensor back onto the wire.

Inputs and outputs

  • MOTORWAY πŸšŒπŸ’¨ - the bus, required.
  • INPUT_mask_key - key of the mask to crop, default mask.
  • x / y - top-left corner of the crop box in pixels (0–16384).
  • width / height - size of the crop (1–16384, defaults 512Γ—512).
  • OUTPUT_MASK_key - key for the cropped mask, default MASK.

Output is the updated MOTORWAY πŸšŒπŸ’¨; read the mask back out with a Motorway AxB ramp node. A note on the box: x/y/width/height here are plain widget integers you set on the node - they don't come from the bus, so if your box should follow something dynamic like a face-detection bbox, you'll want to write those ints into the Motorway upstream and... well, this variant won't read them. That's a real limitation of the auto-generated clone: only non-primitive inputs become keys.

Installing

With the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/agilly1989/ComfyUI_agilly1989_motorway

Restart, or use ComfyUI Manager ("ComfyUI_agilly1989_motorway"). No deps, no models.

The fine print

The pack is an active beta - the README opens "BIG BROKEN WITH ASYNC WILL FIX WHEN I GET THE TIME/MOTIVATION" - and in the version I checked the _motorway_edition clones are commented out of __init__.py; re-enable the ClonedNodeMapping import if the node doesn't show up. Keys are exact and case-sensitive, and the signature error 'MotorwayClass' object has no attribute 'hash_' means you typed a key that isn't in the bus. For a single crop, the plain core CropMask is simpler; this one only earns its keep once you're committed to running masks through the Motorway.

Categoryagilly1989 Nodes/Motorway-ed/mask

Inputs (7)

NameTypeDefaultDescription
MOTORWAY πŸšŒπŸ’¨MOTORWAY πŸšŒπŸ’¨β€”
INPUT_mask_keySTRINGmaskβ€”
xINT00–16384β€”
yINT00–16384β€”
widthINT5121–16384β€”
heightINT5121–16384β€”
OUTPUT_MASK_keySTRINGMASKβ€”

Outputs (1)

NameTypeDescription
MOTORWAY πŸšŒπŸ’¨MOTORWAY πŸšŒπŸ’¨β€”