Nodes/ComfyUI-Transformers/Image Feature Extraction
ComfyUI Node

Image Feature Extraction

Image Feature Extraction

By kadirnar·Created 3 years ago·Updated 7 months ago· 25
Image Feature Extraction
  • image
  • features_json
model_namegoogle/vit-base-patch16-224

Image Feature Extraction is the node that turns a picture into numbers - a long vector of floats that captures what the image "is" to a neural network. In ComfyUI terms, it's a bridge out of the pixel world and into embedding space: the kind of thing you'd use to build a reverse image search, cluster a batch of images by similarity, or feed a vision model's understanding into a downstream step of a bigger pipeline.

Under the hood it's the image-feature-extraction pipeline from Hugging Face Transformers, defaulting to google/vit-base-patch16-224 - the classic ViT image encoder. The node takes the first frame of your image tensor, converts it to PIL, runs it through the model, and hands back the features. It's a pure encoder: no caption, no classification, no labels. You get the raw representation.

The inputs and output

  • image - the IMAGE tensor to embed. First frame only, same as the rest of the pack.
  • model_name - the Hub model ID, typed as a string. Default google/vit-base-patch16-224; any model that supports the image-feature-extraction task works.

The single output, features_json, is a STRING containing JSON with two fields: shape (the dimensions of the embedding, typically [197, 768] for ViT - one vector per patch plus the class token) and features_preview (the first few rows, truncated so the string doesn't explode into thousands of floats). That truncation is deliberate - a full 197×768 embedding is a lot of text.

How to install it

Standard pack install - ComfyUI Manager (search "ComfyUI-Transformers") or:

cd ComfyUI/custom_nodes
git clone https://github.com/kadirnar/ComfyUI-Transformers

Restart ComfyUI. The pack's requirements.txt handles the stack (transformers>=4.42, torch, numpy, Pillow), and ViT-base is a small download on first use.

Where people get burned

This is one of the pack's most "developer-y" nodes, and the practical friction is that you get JSON text, not a tensor. If your downstream step needs actual vector math, you'll be parsing that JSON and reconstructing the array yourself - there's no native VECTOR output type, so it's awkward to chain into similarity comparisons without a bit of glue. Also remember the output is a preview, not the full embedding: for a genuine 197×768 vector you're only seeing the first five rows. It's a capable little node if your goal is inspecting what a vision encoder sees, or prototyping an embedding pipeline; for heavy vector work, a dedicated embedding workflow will save you the parsing.

CategoryTransformers/ImageFeatureExtraction

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
model_nameSTRINGgoogle/vit-base-patch16-224

Outputs (1)

NameTypeDescription
features_jsonSTRING