Pt Size To Numpy
Turn a tensor shape into a NumPy array
- sz
- NDARRAY
Pt Size To Numpy converts a PTSIZE - this pack's shape object - into a NumPy array of integers. It's one of the pack's little interoperability bridges: the shape of a tensor becomes ordinary numeric data you can feed into anything that eats numbers. You'll reach for it when you want to do actual arithmetic on a shape - like computing a derived size, comparing dimensions programmatically, or handing a shape to a node that expects an NDARRAY rather than a PTSIZE.
What it actually does
It's a wrapper around np.array(sz, dtype=int). One PTSIZE in, one NDARRAY out. Give it a size of torch.Size([2, 3, 96, 32]) and you get a NumPy array [2 3 96 32] of integer type. No configuration, no options - the only input is sz, the PTSIZE to convert, and the only output is the NDARRAY.
The practical value is that it moves a shape into the pack's NumPy world, where the same pack has other nodes that consume NDARRAY - you can compute on it, transform it, or pass it along to numpy-flavored steps in your workflow. It's also just a clean way to see a shape as plain numbers when you need it outside the size-node ecosystem.
Only one input:
- sz - a
PTSIZEfrom Pt Size or Pt Size Create.
Output is a single NDARRAY of the dimension values.
How to install it
It's part of the ComfyUI-Pt-Wrapper pack. ComfyUI Manager: search ComfyUI-Pt-Wrapper, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
Restart after. The pack's requirements.txt is the heavy training stack (transformers, datasets, accelerate, peft, gensim, sentencepiece, pandas, scikit-learn, scipy). NumPy itself is a base dependency of the whole pack, so no extra download here - but the rest of the stack still makes first install slow and prone to version conflicts with other nodes.
Gotchas
The type mismatch is the thing to keep in mind. An NDARRAY and a PTSIZE are different types in this pack, and they don't wire into the same consumers. If a node is refusing a connection, check whether it wants PTSIZE (use Pt Size or Pt Size Create) or NDARRAY (convert with this node). And the conversion is one-way in practice - there's no reverse node that rebuilds a PTSIZE from an NDARRAY in this set, so plan your conversions so you don't paint yourself into a corner.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| sz | PTSIZE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| NDARRAY | NDARRAY | — |