ComfyUI Node

CAST

The fast, no-frills style transfer node that just takes images

By FuouM·Created 2 years ago·Updated about a year ago· 15
CAST
  • src_img
  • style_img
  • res_img
model_archCAST

CAST is one of the friendliest nodes in the ComfyUI-StyleTransferPlus pack, and the easiest to describe: it's "Domain Enhanced Arbitrary Image Style Transfer via Contrastive Learning," a 2022 SIGGRAPH paper, wrapped as a single node that takes a content image, a style image, and a dropdown. That's it. No size knob, no crop toggle, no strength slider - it works at whatever resolution you feed it and returns the stylized result.

It's also fast, which is the whole point of the paper. CAST is built on an autoencoder with a contrastive-learning objective, which pushes the transfer to keep content structure recognizable rather than melting it into mush. That makes it a genuinely good first node to try in this pack if you just want a quick stylization that doesn't destroy your subject.

How it works

The architecture is a content autoencoder (AE) plus a style-aware decoder (Dec_B), trained with a contrastive loss so the output stays semantically close to the content while adopting the style's look. The node ships two variants:

  • CAST - the standard model.
  • UCAST - the "unified" variant from the follow-up paper ("A Unified Arbitrary Style Transfer Framework via Adaptive Contrastive Learning"), which adds an extra style-encoding branch. Same interface, slightly different look.

The model_arch dropdown is the only control you get. Try both - they're free once the weights are downloaded.

Inputs and outputs

  • src_img - content.
  • style_img - style.
  • model_arch - CAST or UCAST.

Output: res_img (IMAGE) → Preview/Save. That's the entire node. If you want resizing, do it upstream with an ImageScale node - CAST happily processes whatever dimensions come in.

Install - the fiddly part

The node itself installs like every other node in the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/FuouM/ComfyUI-StyleTransferPlus

or search ComfyUI-StyleTransferPlus in ComfyUI Manager and restart.

Then comes the paperwork. CAST needs three model files, two of them from a Google Drive link on the CAST_pytorch repo's Test section, one (vgg_normalised.pth) from its Train section:

ComfyUI/custom_nodes/ComfyUI-StyleTransferPlus/models/vgg_normalised.pth
ComfyUI/custom_nodes/ComfyUI-StyleTransferPlus/models/CAST_model/latest_net_AE.pth
ComfyUI/custom_nodes/ComfyUI-StyleTransferPlus/models/CAST_model/latest_net_Dec_B.pth

If you want the UCAST variant too, mirror that under models/UCAST_model/. The zip you unzip also contains latest_net_Dec_A.pth and test_opt.txt - the README says both are safe to delete; only latest_net_AE.pth and latest_net_Dec_B.pth are used.

Note the vgg_normalised.pth file is shared across CAST, EFDM, and TSSAT in this pack. Download it once, and three nodes light up.

Common issues

  • Missing model file errors - the CAST/UCAST weights and vgg_normalised.pth must sit at the exact paths above, inside the custom node folder. That's the number one failure mode.
  • No stylization, just a tint - try the other model_arch. CAST and UCAST genuinely produce different results, and the right one depends on your style image.

CAST is the "just works" node of the pack once the downloads are done: two images in, one dropdown, no tuning loop. If that's what you're after, start here.

CategoryStyleTransferPlus

Inputs (3)

NameTypeDefaultDescription
src_imgIMAGE
style_imgIMAGE
model_archCOMBOCAST2 options: CAST, UCAST

Outputs (1)

NameTypeDescription
res_imgIMAGE