Pt From Numpy
Hand a numpy array to PyTorch without losing its dtype
- array
- TENSOR
Pt From Numpy converts a numpy ndarray into a PyTorch TENSOR while keeping the data type intact. If your workflow touches numpy at all - which happens the moment you're doing data analysis next to the image pipeline - this is the node that gets numpy data into the PyTorch graph so the rest of the pack can chew on it.
How it works
Under the hood it's a one-liner: torch.tensor(array, dtype=torch.from_numpy(array).dtype). The "preserve the dtype" part is the whole point - an int64 array stays int64, a float64 array stays float64, a uint8 image array stays uint8. That matters, because PyTorch is picky about types and a silent cast to float32 can break later ops (or at least change their results). You get exactly the array you put in, just in tensor clothing.
The NDARRAY input type comes from this same pack - Pt To Numpy is the obvious producer, and Pt Size To Numpy also emits one. So the normal round-trip is: tensor → numpy (to use a numpy-based library or op) → back to tensor via this node. It's also handy when you have data generated outside ComfyUI sitting in numpy and you want it in the graph.
The one input
- array - an
NDARRAY. Nothing else to configure.
If your data is already a ComfyUI image or latent, don't bother with the numpy detour - Pt From Image and Pt From Latent exist for exactly that.
Where people get burned
- dtype carry-over surprises: the output tensor is not necessarily float32. If the next node quietly assumes float32 (most of the pack's math does fine either way, but some loss/model nodes expect floats), a uint8 or int64 tensor can throw a dtype error. Cast explicitly if you need float.
- Not really "free": the node copies data in the conversion. For huge arrays that's a real memory hit; for anything reasonable it's nothing.
- Wrong producer: feeding a plain tensor here won't connect - the socket wants
NDARRAY, notTENSOR.
Installing it
Part of ComfyUI-Pt-Wrapper:
- ComfyUI Manager → search "ComfyUI-Pt-Wrapper" → Install → restart.
- Or
cd ComfyUI/custom_nodes && git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapperand restart.
The pack installs a hefty ML stack (transformers, datasets, peft, accelerate, scikit-learn, scipy, gensim, sentencepiece), so the first boot is slow. numpy comes along with the pack's own requirements, so no separate install. No model files needed. It's a niche educational pack by HowToSD with little community presence online; lean on the repo's docs/reference/ and the issues tab when something confuses you.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| array | NDARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| TENSOR | TENSOR | — |