Nodes/ComfyUI_DeepFakeDefenders/DeepFakeDefender_Loader
ComfyUI Node

DeepFakeDefender_Loader

Load the ensemble, never touch it again

By smthemex·Created 2 years ago·Updated 2 years ago· 41
DeepFakeDefender_Loader
    • net
    • transform_val
    ckpt_pathDeepFakeDefender

    This node does one job and does it quietly: it loads a trained deepfake-detection model so its partner node, DeepFakeDefender_Sampler, can score images. You set it up once, wire its two outputs into the sampler, and then you never think about it again. That's the whole point - it exists so you don't have to write a line of Python to get a pretrained classifier into your graph.

    The model it loads is the real deal, not a toy. This pack wraps the 1st-place solution to the Global Multimedia Deepfake Detection competition's Image Track, by the "JTGroup" team (upstream repo: HighwayWu/DeepFakeDefenders). The architecture, MFF_MoE, is a mixture-of-experts ensemble: two ConvNeXt-Tiny backbones, a pair each of EfficientNet-B4 and B5, and one B6, all averaged together. The interesting bit is that inference uses EMA weights - an exponential-moving-average snapshot of each expert (decay 0.995) - which is a training trick that usually generalizes better than the raw weights. The loader pulls both weight.pth (the experts) and ema.state (the moving averages) and combines them, so you don't have to think about which one to use.

    The one input

    • ckpt_path - a string, default "DeepFakeDefender". This is a folder name under ComfyUI/models/, not a path to a file. The node looks in ComfyUI/models/DeepFakeDefender/ for weight.pth and ema.state, and will even create the folder if it doesn't exist (which only really helps if you downloaded the weights into the wrong place).

    That's it. Everything else is handled.

    The two outputs

    • net - the loaded model, typed as MODEL so it plugs into the sampler's net input.
    • transform_val - typed as MODEL too, which is a lie: it's actually a torchvision preprocessing pipeline (ToTensor, ImageNet normalization, resize to 512×512). The author reuses the MODEL type to get a wire through the graph. So when you connect it, you're passing a transform, not a model. It works; it's just not what the socket name implies.

    Install

    Grab the pack, clone into custom_nodes:

    cd ComfyUI/custom_nodes
    git clone https://github.com/smthemex/ComfyUI_DeepFakeDefenders.git
    

    Then restart ComfyUI. The model files are the real install step, and they're not auto-downloaded - you grab them from the README's Baidu Cloud or Google Drive links and drop them in:

    ComfyUI/models/DeepFakeDefender/
    ├── ema.state
    └── weight.pth
    

    Where people get burned

    Three gotchas, all visible in the source if you go looking:

    • timm is a hard dependency that isn't in requirements.txt. The requirements file is one big commented-out block (torch, torchvision, transformers, cv2 - all #-prefixed, so pip install -r requirements.txt installs literally nothing). The code actually imports timm, cv2, torchvision, and PIL. Your ComfyUI env almost certainly has torchvision and cv2; it may not have timm. If the Loader dies on import, that's your fix: pip install timm.
    • CUDA only, no graceful fallback. The loader unconditionally runs nn.DataParallel(net).cuda() and even sets CUDA_VISIBLE_DEVICES=0 at module import. There's a device check in the file that contemplates MPS/CPU, but the loader never uses it. On a CPU-only or Apple Silicon box, this node will error - the README's "ComfyUI users should have all this" is optimistic.
    • The license is CC BY-NC 4.0. Non-commercial. Fine for personal experimenting and research; if you're building a commercial content-moderation product on this, that's a licensing conversation you need to have.

    Set the folder name, wire net and transform_val into the sampler, and the loader fades into the background where it belongs.

    CategoryDeepFakeDefender_Gold

    Inputs (1)

    NameTypeDefaultDescription
    ckpt_pathSTRINGDeepFakeDefender

    Outputs (2)

    NameTypeDescription
    netMODEL
    transform_valMODEL