Nodes/ComfyUI-Fast-Style-Transfer/Neural Style Transfer
ComfyUI Node

Neural Style Transfer

The original Gatys method, slow and per-image

By zeroxoxo·Created 2 years ago·Updated about a year ago· 74
Neural Style Transfer
  • content_img
  • style_img
  • IMAGE
content_weight100000
style_weight30000
tv_weight1.0
num_steps100
learning_rate1.0

This is the node the author almost didn't bother porting. He did it anyway, tagged it "[Experimental]" in the README, and described it honestly: "much slower and not that useful but you can play with it if you want." NeuralStyleTransfer is the classic Gatys-style iterative method - the 2015 original that started all of this - and if FastStyleTransfer is a stamped print, this one is a slow painting done stroke by stroke, per image, every single run.

Here's the fundamental difference from its fast sibling: FastStyleTransfer runs a pre-trained network that restyles in a single pass. This node takes both a content image and a style image as inputs and then optimizes the output pixels directly - for each image, each run - by repeatedly measuring how far the result is from matching the style and content statistics, and nudging the pixels closer. That's why it's flexible in a way the fast node isn't: you can swap in any style image on any run, no training required. And it's why it's slow: roughly 100 steps of full VGG forward-and-backward passes per image.

How it works

The node shells out to a subprocess running the ported Gordic Aleksa neural-style-transfer script. It loads a torchvision pretrained VGG-16, extracts style representations at four ReLU layers (relu1_2 through relu4_3) using Gram matrices, and content from relu2_2. Then it optimizes the image tensor itself - via LBFGS, the same optimizer family as the original implementation - to minimize weighted content, style, and total-variation losses. The three *_weight inputs are exactly those three terms.

One nice side effect: because it pulls VGG straight from torchvision, there's no manual model download. The first run grabs VGG-16 automatically (needs internet), which makes this the zero-setup node of the pack.

The inputs that matter

  • content_img and style_img - both IMAGE inputs from LoadImage nodes. You're not choosing from a fixed model list; every run gets to pick its own pair.
  • num_steps - iteration count, default 100. More steps = more refinement and a lot more waiting.
  • style_weight (default 30000) - how strongly the style texture is applied. It operates in a completely different scale from the fast node's weights, because the loss magnitudes here are enormous. content_weight (default 100000) and tv_weight (default 1) sit in the same large range. If output turns to mush, drop style_weight; if it's noisy, raise tv_weight.

Output is a single IMAGE, wired into SaveImage or anything downstream. And before you ask about video: at this speed, no. This node is for the occasional single-image experiment.

Installing

Same pack, same install: Manager → search "ComfyUI-Fast-Style-Transfer", or clone into custom_nodes/ and restart. No extra models, no dataset, no opencv dependency - just torch and torchvision, which you already have. It's the easiest node here to get running, and the hardest to actually finish running.

The honest verdict

Want an actual painted look that respects both your content and a reference style, and you've got a minute or three per image? It does exactly that. Want throughput, batch consistency, or a repeatable style? Use FastStyleTransfer - train a model with TrainFastStyleTransfer if you need a custom one. This node is the romantic original: you'll reach for it once, be delighted by the result, and then mostly keep it in the drawer.

CategoryStyle Transfer

Inputs (7)

NameTypeDefaultDescription
content_imgIMAGE
style_imgIMAGE
content_weightFLOAT1000001000–1000000
style_weightFLOAT3000010–100000
tv_weightFLOAT1.00–10
num_stepsINT10010–10000
learning_rateFLOAT1.00.0001–1000

Outputs (1)

NameTypeDescription
IMAGEIMAGE