Nodes/comfyui_cv/CV Deep Features
ComfyUI Node

CV Deep Features

A frozen ONNX backbone as a fixed feature extractor: each frame is forwarded to layer_name (an interior bottleneck, NOT the classifier logits) and the activation map is global-average-pooled into one embedding row. This is transfer learning the OpenCV way - cv2.dnn cannot backpropagate, so the backbone stays frozen and a cv2.ml head ('CV Train Classifier') is trained on the embeddings instead. E.g. SqueezeNet 1.1: layer squeezenet0_concat7 -> 512-dim embeddings. The net is pinned to OpenCV's CLASSIC engine where the build still has one (the fused graph engine mis-handles interior taps); classic layer names carry an 'onnx_node!' prefix which is added automatically when the bare name is not found. A wrong layer name or an empty batch yields success=false and an empty (0, 0) array, never an error - but a build with NO classic engine (OpenCV 5.1 removed it) cannot tap an interior layer at all, and that RAISES rather than quietly returning the classifier logits.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Deep Features
  • image
  • features
  • dims
  • count
  • success
model
layer_name
input_size224
scale0.0039
swap_rbtrue
poolingglobal average pool (embedding)
mean_r123.675
mean_g116.280
mean_b103.530
std_r0.229
std_g0.224
std_b0.225
Categoryimage/CV/ml

Inputs (13)

NameTypeDefaultDescription
imageNPARRAY,IMAGEFrames to embed: an IMAGE batch gives one embedding row per frame; an NPARRAY (gray/BGR/BGRA) is a single 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.
modelCOMBOBackbone .onnx from ComfyUI/models/onnx (e.g. squeezenet1.1-7.onnx).
layer_nameSTRINGLayer to tap, e.g. squeezenet0_concat7 (the 'onnx_node!' classic-engine prefix is added automatically if needed). Blank = the model's final output - usually class LOGITS, which transfer worse than an interior bottleneck.
input_sizeINT22416–2048Square net input in px (224 for the ImageNet backbones); frames are resized by blobFromImage.
scaleFLOAT0.00390–1000000Pixel scale factor applied after mean subtraction; 1/255 = 0.0039215... maps 0-255 to the 0-1 range ImageNet models expect.
swap_rbBOOLEANtrueSwap R and B: OpenCV frames are BGR, most ONNX backbones want RGB - leave on.
poolingCOMBOglobal average pool (embedding)How a (C, H, W) activation map becomes one row: average each channel over space (C dims, position-invariant - the standard embedding), or flatten everything (C*H*W dims, keeps layout).
mean_roptFLOAT123.675-255–255RED channel mean subtracted before scaling. Default = ImageNet 0.485 * 255. Set 0 to disable.
mean_goptFLOAT116.280-255–255GREEN channel mean (ImageNet 0.456 * 255).
mean_boptFLOAT103.530-255–255BLUE channel mean (ImageNet 0.406 * 255).
std_roptFLOAT0.2290.000001–255RED channel std the scaled pixels are divided by (ImageNet 0.229). Set 1 to disable.
std_goptFLOAT0.2240.000001–255GREEN channel std (ImageNet 0.224). 1 disables.
std_boptFLOAT0.2250.000001–255BLUE channel std (ImageNet 0.225). 1 disables.

Outputs (4)

NameTypeDescription
featuresNPARRAY(N, D) float32 embeddings, one row per frame - feeds 'CV Train Classifier' / 'CV Stack Feature Classes'. Empty (0, 0) on failure.
dimsINTEmbedding length D (512 for SqueezeNet's squeezenet0_concat7).
countINTFrames embedded.
successBOOLEANFalse when the layer name does not exist in the model or no frame could be embedded - gate downstream training with if/else.