Add Magic Clothing Attention
The node that makes the jacket stay the jacket
- sourceModel
- magicClothingModel
- clip
- feature_image
- MODEL
This is the heart of the pack's native Magic Clothing path - the node that actually makes a generated person wear your jacket instead of some vague approximation of a jacket. If you've loaded a virtual try-on workflow and it works, this is why.
It's one half of a two-node setup. First Load Magic Clothing Model gives you two MODEL outputs from your checkpoint: the original sourceModel and the magicClothingModel (the checkpoint's UNet with the Magic Clothing adapter weights blended in). Then this node reads the clothing reference off the magicClothingModel, and bakes that information into the sourceModel so your sampler can use it. Its output MODEL is what you plug into a KSampler.
How the trick works
The core idea from the Magic Clothing paper is that you capture the attention activations the clothing image produces, then replay them during generation. Under the hood the node:
- Runs one forward pass of the magic-clothing UNet on your clothing latent (feature_image) with an empty-prompt CLIP encoding, using a patch that records the self-attention query activations for every UNet block.
- Clones your source model and installs three patches on it: one that concatenates the stored clothing features into the query (and key/value) at those same blocks during denoising, one that computes attention and then chops the extra features back off, and a CFG wrapper that implements the paper's feature guidance.
The feature-guidance CFG is the clever bit. Normal CFG is uncond + scale * (text - uncond). Magic Clothing uses a three-branch version:
noise_pred = uncond + cfg * (text - cloth) + feature_guidance_scale * (cloth - uncond)
The text branch drives "a model standing in a studio," the cloth branch drives "that specific coat," and feature_guidance_scale (default 2.5) sets how hard the garment sticks. Because this node reaches into ComfyUI internals (comfy.samplers.get_area_and_mult and friends), it's sensitive to ComfyUI updates - expect the occasional breakage when you update ComfyUI.
The inputs that matter
sourceModelandmagicClothingModel- both fromLoad Magic Clothing Model. Wire them in the right order or nothing works.clip- the same CLIP from your checkpoint loader.feature_image(LATENT) - a VAE-encoded crop of the garment. This is where you put the output of VAEEncode after cutting your clothing photo out of its background. It must match the width and height of the image you're generating - the code raises "Your featured image must be the same width and height as the image you want to generate!" if they disagree, and it will refuse to run.enable_feature_guidance(BOOLEAN, default true) - kill switch for the cloth guidance branch.feature_guidance_scale(FLOAT, default 2.5) - the dial you'll actually turn. Too low and the garment drifts; too high and the person starts wearing the jacket as their skin.
Output is a single MODEL, straight into a KSampler. The example workflow pairs it with uni_pc / normal, 20 steps, CFG 5, and the Realistic Vision checkpoint.
Install and models
ComfyUI Manager → search "comfyui-magic-clothing", or:
cd ComfyUI/custom_nodes
git clone https://github.com/longgui0318/comfyui-oms-diffusion
# restart
You need the adapter UNet from ShineChen1024/MagicClothing on HuggingFace (e.g. magic_clothing_768_vitonhd_joint.safetensors) in ComfyUI/models/unet, plus a base SD 1.5 checkpoint. The example workflows also use BiRefNet to cut the garment out of its photo before you VAE-encode it - the cutout quality directly affects the result.
Honest expectations
The pack's README is refreshingly blunt: success rate is low, dense patterns come out wrong, and the author admits the first-UNet-step handling is still being worked on. (An earlier version of this node exposed a sigma parameter as a temporary input-scaling fix; it's been removed.) Treat this as a reroll-until-it-works tool, and keep your garment photos simple - solid colors and clear silhouettes try on far better than busy prints. The upside, per the README, is that the patched model plays nice with IP-Adapter, so you can stack image prompting on top of the try-on.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| sourceModel | MODEL | — | |
| magicClothingModel | MODEL | — | |
| clip | CLIP | — | |
| enable_feature_guidance | BOOLEAN | true | — |
| feature_image | LATENT | — | |
| feature_guidance_scale | FLOAT | 2.50–10 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |