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

Train Fast Style Transfer

Train your own style model in ComfyUI — one image, a COCO download, and patience

By zeroxoxo·Created 2 years ago·Updated about a year ago· 74
Train Fast Style Transfer
  • style_img
    seed30
    content_weight14
    style_weight50
    tv_weight0
    batch_size4
    train_img_size256
    learning_rate0.0010
    num_epochs1
    save_model_every500
    from_pretrained0
    model

    FastStyleTransfer is only useful if a style you actually want exists as a .pth file. The bundled seven cover a few classic painterly looks, but if you want your own style, this is the node that makes it. TrainFastStyleTransfer trains a feedforward style-transfer network inside ComfyUI - no LoRA, no diffusion, no per-image optimization. You give it one style image, it trains a small network (~6 MB) that will then restyle anything in that look in a fraction of a second.

    The trade-off to understand before you queue it up: this is real training, not a one-click effect. The README is blunt about what it needs, and the two downloads are the actual gate.

    What you must download first

    The node shells out to a training script that needs two things sitting in the right folders inside the pack directory:

    • VGG-16 weights - drop vgg16-00b39a1b.pth (from the jcjohnson/pytorch-vgg repo) into the vgg/ folder. The training loss runs through VGG's feature maps, so there's no training without it.
    • An MS COCO train dataset - the original repo suggests the 13 GB train-2014 set, which the README warns is "13Gb" for a reason. The much saner route: the downscaled 256×256 train-2017 torrent (about 1.64 GB), which is the same resolution the original repo trained at anyway. Put the folder into dataset/.

    If either is missing, training dies early. This is the #1 way people bounce off this node.

    The inputs that matter

    Mostly three knobs plus one shortcut:

    • style_img - the single reference image that defines the style. One image per style is the whole model; as the author put it, the network learns pure pattern recognition, not any semantic content.
    • style_weight - how aggressively the style applies. The README's suggestion: raise it for more style, and treat tv_weight (total-variation loss, default 0.001) as the sharpness control for how the style textures render. Both are "experiment" dials.
    • save_model_every - how many steps between checkpoints. This is the one that makes the node usable: set it to 100–200 and it saves a model and a test image into the models/ and output/ folders as it goes, so you can watch the style emerge without waiting for the whole job.

    The rest - seed, content_weight, batch_size, train_img_size, learning_rate, num_epochs - have sane defaults. The README's advice: batch_size barely helps, keep 4 at 256×256; don't run the full epoch, just train until total loss stops reliably dropping. And the shortcut: set from_pretrained to 1 and it starts from one of the bundled models instead of scratch, which the README says cuts training time drastically - often a good model in under 2000 steps.

    Note the node returns nothing. It's an output node; the results are files in the pack's models/ folder, which you then pick up in FastStyleTransfer.

    Installing

    Same as the rest of the pack: ComfyUI Manager → search "ComfyUI-Fast-Style-Transfer", or git clone https://github.com/zeroxoxo/ComfyUI-Fast-Style-Transfer into custom_nodes/, restart. Training additionally needs opencv-python (the script uses cv2 to write preview images), which isn't a standard ComfyUI dependency - if preview saving errors, pip install opencv-python in your ComfyUI environment.

    Gotchas worth knowing

    The node's paths are hardcoded to the pack's own folders, so clone it under the exact name ComfyUI-Fast-Style-Transfer or nothing lines up. Training is a long blocking queue item - ComfyUI will sit on it for a while, which is exactly why save_model_every is your friend: when a checkpoint looks good, just close the training job, test the models you saved, delete the rest, and rename the winner. As a first ComfyUI node from the author (who was upfront about that in the announcement thread), expect rough edges - but the core loop is genuinely workable.

    CategoryStyle Transfer

    Inputs (12)

    NameTypeDefaultDescription
    style_imgIMAGE
    seedINT300–999999
    content_weightINT141–128
    style_weightINT501–128
    tv_weightFLOAT00–1
    batch_sizeINT41–32
    train_img_sizeINT256128–2048
    learning_rateFLOAT0.00100.0001–100
    num_epochsINT11–20
    save_model_everyINT50010–10000
    from_pretrainedINT00–1
    modelCOMBO7 options: udnie.pth, lazy.pth, mosaic.pth, bayanihan.pth, starry.pth, wave.pth, +1

    Outputs (0)

    No outputs