Nodes/ComfyUI_AnyDoor/AnyDoor_LoadModel
ComfyUI Node

AnyDoor_LoadModel

Two giant model files, one dropdown

By smthemex·Created 2 years ago·Updated 2 years ago· 69
AnyDoor_LoadModel
    • model
    • ddim_sampler
    • info
    save_memoryfalse
    ckpts

    AnyDoor_LoadModel is the boring half of ComfyUI_AnyDoor, and you can't run the fun half without it. It's a thin ComfyUI wrapper around AnyDoor, Alibaba DAMO's 2023 zero-shot object-editing model - the thing that lets you lift a coat off one image and paste it onto a person in another, or pick an object up and drop it somewhere new in the scene. Before the img2img node does any of that, this node has to build the model, drag several gigabytes of weights off the internet, and hand you a sampler. That's its whole job, and it's where most of this pack's setup pain lives, so it's worth understanding before you touch anything downstream.

    What it actually loads

    AnyDoor isn't a checkpoint you'd load with ComfyUI's built-in loader. The repo wraps a ControlNet-style latent diffusion model: an SD 1.5 UNet, plus a frozen DINOv2 ViT-g encoder that reads the identity of the object you're transferring, plus a four-channel "hint" branch that carries shape. The node instantiates that whole assembly from a yaml config, loads the state dict, and - importantly - moves it to CUDA. There is no CPU path here; no NVIDIA GPU with enough VRAM means this pack will not run, full stop.

    The inputs are deliberately sparse, and only one deserves your attention:

    • ckpts - pruned pulls the 4.9 GB epoch=1-step=8687-pruned.ckpt; origin pulls the 16.8 GB full checkpoint. Just use pruned. The pack itself thanks 青龙聖者 (bdsqlsz) for the pruned file, and it's the one the community actually runs. Nobody is getting meaningfully better results out of the 16.8 GB file.
    • save_memory - a boolean meant to enable sliced attention and VRAM offloading on small cards. More on it below, because there's a wrinkle.

    The three outputs, and why they look weird

    • model - the model object. Wires into AnyDoor_img2img.
    • ddim_sampler - a DDIM sampler object dressed up as a MODEL type. It is not a standard ComfyUI model, but you still have to plug it into the img2img node.
    • info - a string carrying the save_memory flag as "true"/"false". It's a wiring hack to smuggle that flag through the graph, and the img2img node requires it with forceInput. Leave it unplugged and the pipeline won't run.

    So the mental model is simple: load this node, then wire all three outputs into AnyDoor_img2img. Don't skip info because it looks optional.

    Getting the weights

    The first time the node executes, it auto-downloads from modelscope (the Chinese model hub) into ComfyUI/models/anydoor/:

    • dinov2_vitg14_pretrain.pth (4.5 GB)
    • whichever checkpoint you picked above

    If you're outside China, modelscope can be slow or flaky, and the failure shows up as a cryptic modelscope error at execution time. The README's escape hatch: pre-download the files yourself - the pruned checkpoint and DINOv2 weights live on the bdsqlsz/AnyDoor-Pruned modelscope repo, and the DINOv2 file is also on facebookresearch's official repo - then drop them in that folder. Once they're on disk, the modelscope library isn't even needed.

    Installing the pack

    ComfyUI Manager (search "ComfyUI_AnyDoor") or the manual route:

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

    The actual requirements are light: modelscope, open_clip_torch, pytorch_lightning. The README offers a fallback: rename for_modules_miss_requirements.txt to requirements.txt and install it. Don't. That file pins torch==2.0.0 and xformers==0.0.18 alongside a pile of old pinned libraries - installing it will downgrade the torch the rest of your ComfyUI depends on, and 0.0.18 has a documented black-image regression at high resolutions. If a module is missing, pip install <that module> individually instead.

    Troubleshooting worth knowing

    • Download stalls or errors → pre-download the weights as above; that's the standard fix, and it's the one the author suggests.
    • save_memory is half-broken in the shipped version → the loader does enable sliced attention, but the flag is relayed through that info string and the img2img side compares against a misspelled value, so the VRAM-offload half never actually engages. Treat it as a light-helpful switch, not a guarantee on a 6 GB card.
    • Out of memory even on pruned → the model plus a ViT-g encoder is hungry; the 16.8 GB origin checkpoint is strictly worse, so double-check your dropdown says pruned.

    Once this node loads cleanly, the hard part is done. Everything else in the pack is downstream of it.

    CategoryAnyDoor

    Inputs (2)

    NameTypeDefaultDescription
    save_memoryBOOLEANfalse
    ckptsCOMBO2 options: pruned, origin

    Outputs (3)

    NameTypeDescription
    modelMODEL
    ddim_samplerMODEL
    infoSTRING