StyleScore
The Gram-matrix metric that measures the 'feel' of an image
- image_a
- image_b
- style_loss
ContentScore measures what's in the picture. StyleScore measures how it's painted. It's the classic style-transfer StyleLoss - VGG features compared via their Gram matrices, which capture the correlations between feature activations at each layer. Roughly: the Gram matrix of a painting tells you about its brushwork, color harmony, and texture without caring where any of it sits. As a standalone metric, StyleScore answers "does this image have the same stylistic feel as the reference, even if the subject changed?" Lower is better - 0.0 means the styles match exactly.
It's one of the seventeen nodes in comfyui-piq, Laurent Fainsin's wrapper around the piq library.
How it works. Both images pass through a VGG network (vgg16 or vgg19), and at several layers (piq uses relu1_2, relu2_2, relu3_3, relu4_3 by default) the features are turned into Gram matrices - outer products of the feature channels that encode "which texture/color patterns tend to co-occur here." Those Gram matrices from both images are compared with a distance (mse/mae), weighted, and pooled (reduction) into the score. Because Gram matrices drop spatial location, two images can share a style score while depicting totally different scenes - that's the feature, not a bug. normalize_features and replace_pooling are the same tuning knobs as ContentScore.
Shared gotcha: VGG weights download on first run. vgg16/vgg19 are ImageNet-pretrained, torchvision fetches them from pytorch.org (~528–549 MB) on first use and caches in ~/.cache/torch. First run needs internet; every run after is local.
Inputs a beginner actually sets:
image_a/image_b- candidate vs. reference;image_bis ground truth.feature_extractor-vgg16(default) unless you need the extra depth ofvgg19.distance/reduction-mseandmeanfor one comparable number.
The style_loss output is a FLOAT, lower better.
Installing. ComfyUI Manager, search "comfyui-piq", Install. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/Laurent2916/comfyui-piq.git
pip install -r custom_nodes/comfyui-piq/requirements.txt
Requirements is one line (piq>=0.8.0); Python 3.12+; repo archived but functional.
The honest take. StyleScore is the node you reach for when your question is genuinely about style - "did this LoRA reproduce the target artist's texture and palette," "is this img2img pass preserving the original's look." It's a real metric with a real job, but it's also the most easily misunderstood one here: a low style score tells you nothing about whether the subject matches. Run it with ContentScore if you want both axes, and remember both are deep-feature distances - same weight-download caveat, same "GPU helps" advice as LPIPS.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image_a | IMAGE | Input image | |
| image_b | IMAGE | Reference image | |
| feature_extractor | COMBO | Neural network for feature extraction | |
| replace_pooling | BOOLEAN | false | Replace max pooling with average pooling |
| distance | COMBO | Distance metric | |
| reduction | COMBO | Reduction method | |
| normalize_features | BOOLEAN | false | Whether to normalize extracted features |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| style_loss | FLOAT | Style Loss Based on Deep Features |