DataSize (Yogurt Nodes)
The 'how big is this thing' node your workflows quietly need
- data
- size
DataSize answers one dumb question that comes up constantly once you start stringing logic into your graphs: how many things are in this thing? Feed it a list, a dictionary, a string, even a tensor, and it hands back an integer length. That's it. But that single number unlocks a surprising amount of workflow behavior.
The typical use is guarding batch operations. Say you've got a variable number of images coming out of some upstream node and you need to decide whether to run a second pass, or you want to abort early when a list is unexpectedly short. size gives you a number you can feed into a Switch, a compare, or an If - "if batch size < 4, don't bother upscaling" is a real pattern people build. It's the same idea as the pack's DictLength and ListLength nodes, but without caring what kind of container you plugged in.
How it works
The mechanism is dead simple: it calls Python's len() on whatever you hand it, and if the object doesn't support len() at all - an int, a None, a random custom object - it falls back to the default_size you set instead of crashing. That fallback is the whole reason it's more useful than a raw length node: your graph keeps running instead of throwing a TypeError when a node upstream feeds it something odd.
One thing worth knowing: len() on a torch tensor returns the first dimension, i.e. the batch size, not the pixel count. If you're feeding it image tensors, the number you get is "how many images in the batch," which is usually exactly what you want. For a dict, you get the number of keys; for a string, the number of characters.
Inputs
data- anything you want measured.default_size- the integer to return whenlen()isn't possible. Defaults to 0, so an unmeasurable object reads as "empty" unless you tell it otherwise.
Output
size- an INT you can wire into any numeric input or logic node.
Install
Ships in ComfyUI-YogurtNodes; install the pack once and it's there under "Yogurt Nodes" → Logic:
cd ComfyUI/custom_nodes
git clone https://github.com/yogurt7771/ComfyUI-YogurtNodes.git
cd ComfyUI-YogurtNodes
pip install -r requirements.txt
Or search "YogurtNodes" in ComfyUI Manager and restart.
Common issues
- "It says 0 but the list clearly has stuff" - check what type you actually plugged in. A dict-like object that doesn't implement
len()(rare, but some wrapped objects) will hit the fallback and returndefault_size. - "I expected pixels, got a batch number" - remember tensors measure by first dimension. For dimensions, use a dedicated image-size node (
YogurtGetImageSizein the same pack). - Fallback hiding bugs - because it never errors, a genuinely broken upstream can silently read as size 0. If your logic starts doing weird things, don't assume
datawas valid.
Thin node, genuinely handy once your graphs grow past "load, sample, save." If you only ever run fixed-size workflows, you can skip it; the moment things get dynamic, you'll go looking for it.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| data | * | Data structure to measure | |
| default_sizeopt | INT | 0 | Default size for non-measurable objects |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| size | INT | — |