ComfyUI Node
CV DNN Blob From Image
Builds a cv2.dnn input blob from an IMAGE batch or a single image: an optional resize, per-channel mean subtraction, a scale factor and a BGR<->RGB swap, packed into the (N, C, H, W) NCHW float32 tensor a network's setInput() expects. Encodes every frame in the batch (single image gives N=1). Generic PREPROCESS step - feed the blob into 'CV DNN Forward'.
CV DNN Blob From Image
- image
- blob
◄scale1.000►
◄width0►
◄height0►
◄swap_rbtrue►
◄mean_r0.0►
◄mean_g0.0►
◄mean_b0.0►
◄cropfalse►
Categoryimage/CV/dnn
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image | NPARRAY,IMAGE | IMAGE batch to encode. Every frame is resized and encoded; an NPARRAY (gray/BGR/BGRA, any dtype) is treated as a single BGR frame. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size. | |
| scale | FLOAT | 1.0000–1000000 | Multiplies every pixel (after mean subtraction). Use 1/255 = 0.003921 to map 0-255 pixels into the 0-1 range most ONNX models expect; 1.0 leaves them at 0-255. |
| width | INT | 00–8192 | Resize width the network wants, in px. 0 = keep the image's own width (for fully-convolutional models). |
| height | INT | 00–8192 | Resize height the network wants, in px. 0 = keep the image's own height. |
| swap_rb | BOOLEAN | true | Swap the R and B channels. OpenCV frames are BGR but most ONNX models are trained on RGB, so leave this on. |
| mean_ropt | FLOAT | 0.0-255–255 | Value subtracted from the RED channel before scaling (0 = none). Set the model's training mean if needed. |
| mean_gopt | FLOAT | 0.0-255–255 | Value subtracted from the GREEN channel before scaling (0 = none). |
| mean_bopt | FLOAT | 0.0-255–255 | Value subtracted from the BLUE channel before scaling (0 = none). |
| cropopt | BOOLEAN | false | On: resize so the shorter side fits then centre-crop to (width, height). Off: resize the whole image (may change aspect ratio). |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| blob | NPARRAY | (N, C, H, W) float32 NCHW blob for the whole batch. Feed 'CV DNN Forward'. Empty (0, 3, 1, 1) for an empty IMAGE batch. |