Nodes/ComfyUI_MagicClothing/Human Garment Inpainting
ComfyUI Node

Human Garment Inpainting

Put a real garment on a real person, seams and all

By frankchieng·Created 2 years ago·Updated 2 years ago· 594
Human Garment Inpainting
  • cloth_image
  • cloth_mask_image
  • person_image
  • person_mask
  • images
model_path
prompta photography of a model
pipe_path
enable_cloth_guidancetrue
num_samples1
negative_promptbare, monochrome, lowres, bad anatomy, worst quality, low quality
seed42
guidance_scale5.0
cloth_guidance_scale2.5
sample_steps20
height768
width576

This is the node that actually does virtual try-on the way you hope it works: you feed it a photo of a person, a photo of a garment, masks for both, and it puts the actual garment on the actual person - fabric, folds, print and all. Not a prompt describing "a red hoodie", the real shirt from your product shot. It's the pack's flagship and its most-used node, and if you came here from Google it's probably the one you want.

The other two nodes in the pack (Generate, AnimateDiff) synthesize a model to wear your clothes. This one starts from a real human photo and respects it. The person keeps their pose, their lighting, their body - the garment is inpainted onto them.

How it works

Under the hood this is a full diffusers pipeline wrapped in one node, not a normal ComfyUI sampler chain - more on that below. It runs a StableDiffusionControlNetInpaintPipeline with the lllyasviel/control_v11p_sd15_inpaint ControlNet. The person's mask is turned into a conditioning image (masked pixels set to a fixed value), so the model only regenerates the clothing region, and the garment reference is injected through MagicClothing's "cloth guidance" attention mechanism - a reference UNet whose attention maps condition the denoising. Both guidance_scale and cloth_guidance_scale steer that: the first controls prompt adherence, the second how hard the garment reference is held. Crank cloth_guidance_scale up when the print or cut is drifting, back off when the result starts looking glued-on.

The inputs that matter

Eight required inputs, but really only a few you touch:

  • person_image + person_mask - the photo of your human and a mask covering them (where the garment goes). person_mask is a MASK, not an image, so wire it from a segmentation or SAM output.
  • cloth_image + cloth_mask_image - the garment photo and a mask of just the garment. The author's README says he cut the cloth out with Segment Anything; anything that segments cleanly works, and a tight mask matters more here than anywhere else.
  • model_path - the MagicClothing adapter .safetensors sitting in the node's checkpoints/ folder. It only lists files that are directly in that folder; wrong location = empty dropdown.
  • pipe_path - the base SD 1.5 model. Defaults to SG161222/Realistic_Vision_V4.0_noVAE, with dreamshaper-8 and xxmix_9realistic as alternates. First run downloads it from HuggingFace, so have a few GB of bandwidth and patience ready.

Worth setting: num_samples (how many tries), seed, and height/width (defaults 768×576). The output is a single images tensor you can save or preview like any ComfyUI generation.

Installing it

Either install through ComfyUI Manager (search "ComfyUI_MagicClothing"), or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/frankchieng/ComfyUI_MagicClothing.git
cd ComfyUI_MagicClothing
pip install -r requirements.txt

Then restart ComfyUI. You also need the model files from ShineChen1024/MagicClothing on HuggingFace: cloth_segm.pth and a magic_clothing_*.safetensors adapter, placed in the node's checkpoints/ directory.

Where people get burned

The honest warnings, because this is a 2024-era pack and it shows:

  • The requirements pin a 2024 CUDA 11.8 stack - torch==2.1.1+cu118, numpy==1.25.1, transformers==4.31.0. Running pip install -r requirements.txt into a modern ComfyUI environment can downgrade torch and quietly break your other nodes. The ecosystem's standing advice applies hard here: know what you're doing with your Python env before you run it, or install via Manager and hope the resolver is kind.
  • It's a black box. The node runs the entire pipeline internally - you can't splice a KSampler or a different VAE into it. The community called this out the day it shipped, and it's a fair trade: the author wrapped the whole diffusers implementation because converting it to native ComfyUI nodes is a real job.
  • First run downloads a lot - base model, inpaint ControlNet, VAE, segmentation weights. Several GB, all from HuggingFace.
  • It's SD 1.5 quality. Fabric fidelity is decent but not e-commerce-pixel-perfect; people in the threads described the results as "a match for the product shot, not the product." If the garment details matter to the last stitch, budget for a detail pass afterward.

If the dropdown is empty, the adapter isn't in the right folder. If it OOMs, drop height/width or raise cloth_guidance_scale instead of guidance_scale - over-prompting fights the garment.

CategoryMagicClothing

Inputs (16)

NameTypeDefaultDescription
cloth_imageIMAGE
cloth_mask_imageIMAGE
model_pathCOMBO0 options:
promptSTRINGa photography of a model
pipe_pathCOMBO3 options: SG161222/Realistic_Vision_V4.0_noVAE, Lykon/dreamshaper-8, redstonehero/xxmix_9realistic_v40
enable_cloth_guidanceBOOLEANtrue
person_imageIMAGE
person_maskMASK
num_samplesoptINT11–10
negative_promptoptSTRINGbare, monochrome, lowres, bad anatomy, worst quality, low quality
seedoptINT42
guidance_scaleoptFLOAT5.01–10
cloth_guidance_scaleoptFLOAT2.51–10
sample_stepsoptINT201–100
heightoptINT768256–1024
widthoptINT576192–768

Outputs (1)

NameTypeDescription
imagesIMAGE