OpenCV convertFp16_0
Halving your arrays with convertFp16 — but not your images
- src
- dst
- nparray
convertFp16_0 takes a numpy array and converts it to 16-bit floating point - IEEE 754 half precision, half the memory of float32. That's the entire trick, and it's a good one to have around when you're shuttling big float arrays through your graph and RAM is complaining.
The catch, and it's a real one: this is a dtype conversion, not an image operation. OpenCV's cv2.convertFp16 converts a 32-bit float array into a 16-bit float array. It does not resize, recolor, or otherwise make a picture. If you wire a regular photo into it and try to view the result, you're going to be confused - a half-precision version of a BGR uint8 image isn't something Nparrays2Image wants to display, and this is exactly the kind of "the output is a 1-D array of floats but I'm treating it as an image" situation the pack README warns about.
This node is part of geroldmeisinger/opencv-comfyui, the auto-generated pack wrapping hundreds of top-level OpenCV functions. It's a straight cv2.convertFp16 call: src in (NPARRAY), nparray out. There's also an optional dst input - an OpenCV out-parameter - and the pack README's advice applies here: don't feed it unless you specifically know why you want an output buffer. Let OpenCV allocate the result; that's what dst=None does.
What you'd actually use it for
- Halving memory on float32 maps or feature arrays before a big processing stage.
- Feeding float16 data to something that demands half precision.
- Round-tripping with a
convertScaleAbs-style stage... no, stop - honestly this is a niche one. OpenCV nodes shine for "small, quick transformations" (the author's own framing for this pack), and dtype conversion is about as small as it gets.
The real trap is the name colliding with your ComfyUI instincts: everything else in this pack is pixel-level image surgery, and convertFp16 looks like it belongs to that family. It doesn't. It's a memory/format utility. That's fine - but if your mental model is "convert my image," check whether you actually meant cvtColor_0 (BGR↔RGB, grayscale, the pack's real workhorse) or convertScaleAbs_0 (the contrast/brightness one).
Install
Standard for the pack - ComfyUI Manager, search opencv-comfyui, or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-python-contrib
Restart ComfyUI. No model files.
Troubleshooting
- It's not an image node - if
Nparrays2Imagethrows'NoneType' object has no attribute 'shape', you handed it a float array that isn't really a picture. Check the OpenCV docs for what the function actually returns. - Remember this pack's bridge: Comfy
IMAGEis a torch tensor, RGB, 0..1. OpenCV wants numpy, BGR, 0..255. Convert withImage2Nparrayin,Nparrays2Imageout - both single-batch only.
One last note so you don't go hunting: convertFp16_0 and convertFp16_1 are the two numbered overloads of the same function from the type definitions (MatLike vs UMat), and the generated nodes are identical. Pick either.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |