Extensions/ComfyUI's ControlNet Auxiliary Preprocessors
ComfyUI Extension Runs on cloud

ComfyUI's ControlNet Auxiliary Preprocessors

Plug-and-play ComfyUI node sets for making ControlNet hint images.

By Fannovel16·Created 3 years ago·Updated 4 months ago· 4,138
Fannovel16/comfyui_controlnet_aux
Nodes64
On cloudRunnable
CategoryControlNet Preprocessors, ControlNet Preprocessors/Faces and Poses Estimators
Stars4,138
Updated4 months ago

Nodes (64)

AIO Aux Preprocessor

Every ControlNet preprocessor behind one dropdown

ControlNet Preprocessors
AnimalPose Estimator (AP10K)

OpenPose, but for animals

ControlNet Preprocessors/Faces and Poses Estimators
Anime Face Segmentor

Region maps for anime faces, plus a free character mask

ControlNet Preprocessors/Semantic Segmentation
Anime Lineart

Clean line extraction for anime and illustration

ControlNet Preprocessors/Line Extractors
AnyLine Lineart

The high-detail line extractor for MistoLine

ControlNet Preprocessors/Line Extractors
BAE Normal Map

The reliable standard normal estimator, zero knobs

ControlNet Preprocessors/Normal and Depth Estimators
Binary Lines

The dead-simple threshold preprocessor for scribble ControlNet

ControlNet Preprocessors/Line Extractors
Canny Edge

The workhorse edge detector for ControlNet

ControlNet Preprocessors/Line Extractors
Color Pallete

The T2I-Adapter color-scheme preprocessor

ControlNet Preprocessors/T2IAdapter-only
ControlNetAuxSimpleAddText

Burn a text label onto an image

ControlNet Preprocessors
Preprocessor Selector

The dropdown that picks a preprocessor by name

ControlNet Preprocessors
DensePose Estimator

Per-pixel body maps for pose and animation control

ControlNet Preprocessors/Faces and Poses Estimators
Depth Anything

The v1 depth node (and why you probably want v2)

ControlNet Preprocessors/Normal and Depth Estimators
Depth Anything V2 - Relative

The depth map you actually want

ControlNet Preprocessors/Normal and Depth Estimators
Diffusion Edge (batch size ↑ => speed ↑, VRAM ↑)

The sharpest edge maps in the pack, if your VRAM can take it

ControlNet Preprocessors/Line Extractors
DSINE Normal Map

The sharp, modern normal estimator for relighting workflows

ControlNet Preprocessors/Normal and Depth Estimators
DWPose Estimator

The pose detector for OpenPose ControlNet

ControlNet Preprocessors/Faces and Poses Estimators
Execute All ControlNet Preprocessors

The swatch board for picking a preprocessor

ControlNet Preprocessors
Colorize Facial Parts from PoseKPS

Turn face keypoints into a colored region map

ControlNet Preprocessors/Pose Keypoint Postprocess
Fake Scribble Lines (aka scribble_hed)

Turn a photo into a rough scribble for control_scribble

ControlNet Preprocessors/Line Extractors
HED Soft-Edge Lines

The forgiving edge detector for organic subjects

ControlNet Preprocessors/Line Extractors
Enchance And Resize Hint Images

Fit a control map to your render dimensions

ControlNet Preprocessors
Generation Resolution From Image

Read a reference's dimensions into width/height ints

ControlNet Preprocessors
Generation Resolution From Latent

Pull pixel width/height out of a latent

ControlNet Preprocessors
Image Intensity

The other grayscale hint for Recolor ControlNet

ControlNet Preprocessors/Recolor
Image Luminance

The grayscale hint that drives Recolor ControlNet

ControlNet Preprocessors/Recolor
Inpaint Preprocessor

Prep an image and mask for an inpaint ControlNet

ControlNet Preprocessors/others
LeReS Depth Map (enable boost for leres++)

Scene depth with foreground/background cleanup knobs

ControlNet Preprocessors/Normal and Depth Estimators
Realistic Lineart

Natural outlines for photo-based ControlNet

ControlNet Preprocessors/Line Extractors
Standard Lineart

The no-download, all-purpose line extractor

ControlNet Preprocessors/Line Extractors
Manga Lineart (aka lineart_anime_denoise)

Clean lines out of noisy manga and screenshots

ControlNet Preprocessors/Line Extractors
Mask Optical Flow (DragNUWA)

Restrict a motion field to a region for DragNUWA

ControlNet Preprocessors/Optical Flow
MediaPipe Face Mesh

Control faces and expressions with ControlNet

ControlNet Preprocessors/Faces and Poses Estimators
MeshGraphormer Hand Refiner

The node that fixes mangled AI hands

ControlNet Preprocessors/Normal and Depth Estimators
MeshGraphormer Hand Refiner With External Detector

Bring your own hand detector

ControlNet Preprocessors/Normal and Depth Estimators
Metric3D Depth Map

Metric depth from a single photo, camera intrinsics and all

ControlNet Preprocessors/Normal and Depth Estimators
Metric3D Normal Map

The camera-aware normal estimator with size options

ControlNet Preprocessors/Normal and Depth Estimators
MiDaS Depth Map

The original depth estimator, still holding up

ControlNet Preprocessors/Normal and Depth Estimators
MiDaS Normal Map

The old normal estimator where a and bg_threshold finally matter

ControlNet Preprocessors/Normal and Depth Estimators
M-LSD Lines

The straight-line preprocessor for architecture and interiors

ControlNet Preprocessors/Line Extractors
OneFormer ADE20K Segmentor

The higher-quality segmentation map for seg ControlNet

ControlNet Preprocessors/Semantic Segmentation
OneFormer COCO Segmentor

Label every pixel by object for seg ControlNet

ControlNet Preprocessors/Semantic Segmentation
OpenPose Pose

Pose skeletons for ControlNet

ControlNet Preprocessors/Faces and Poses Estimators
PiDiNet Soft-Edge Lines

The softedge preprocessor I'd actually reach for

ControlNet Preprocessors/Line Extractors
Pixel Perfect Resolution

Stop your ControlNet maps from getting rescaled

ControlNet Preprocessors
PyraCanny

Fooocus's pyramid Canny for ComfyUI

ControlNet Preprocessors/Line Extractors
Render Pose JSON (Animal)

Turn animal keypoints back into a skeleton image

ControlNet Preprocessors/Pose Keypoint Postprocess
Render Pose JSON (Human)

Turn edited pose keypoints back into an OpenPose image

ControlNet Preprocessors/Pose Keypoint Postprocess
SAM Segmentor

MobileSAM auto-segmentation as a ControlNet hint

ControlNet Preprocessors/others
Save Pose Keypoints

Dump OpenPose JSON to disk for editing and pipelines

ControlNet Preprocessors/Pose Keypoint Postprocess
Scribble PiDiNet Lines

Cleaner scribble extraction via PiDiNet edges

ControlNet Preprocessors/Line Extractors
Scribble Lines

The plain base scribble preprocessor (and when to skip it)

ControlNet Preprocessors/Line Extractors
Scribble XDoG Lines

Fast, model-free scribble extraction with one knob

ControlNet Preprocessors/Line Extractors
Semantic Segmentor (legacy, alias for UniFormer)

The legacy alias that's really UniFormer under the hood

ControlNet Preprocessors/Semantic Segmentation
Content Shuffle

The T2I-Adapter style preprocessor (and a sneaky variety trick)

ControlNet Preprocessors/T2IAdapter-only
TEEDPreprocessor

The clean, modern edge preprocessor for ControlNet

ControlNet Preprocessors/Line Extractors
Tile

The preprocessor behind faithful detail-adding upscales

ControlNet Preprocessors/tile
TTPlanet Tile GuidedFilter

The tile preprocessor for realistic detail upscaling

ControlNet Preprocessors/tile
TTPlanet Tile Simple

The blur-and-degrade step for tiled upscaling

ControlNet Preprocessors/tile
UniFormer Segmentor

Paint-by-category layout maps for seg ControlNet

ControlNet Preprocessors/Semantic Segmentation
Unimatch Optical Flow

Motion vectors for DragNUWA, the pack's odd one out

ControlNet Preprocessors/Optical Flow
Upper Body Tracking From PoseKps (InstanceDiffusion)

Pose keypoints into InstanceDiffusion tracking boxes

ControlNet Preprocessors/Pose Keypoint Postprocess
Zoe Depth Anything

Zoe's structure with a Depth Anything brain

ControlNet Preprocessors/Normal and Depth Estimators
Zoe Depth Map

The old depth default, and when it still fits

ControlNet Preprocessors/Normal and Depth Estimators
Readme

ComfyUI's ControlNet Auxiliary Preprocessors

Plug-and-play ComfyUI node sets for making ControlNet hint images

"anime style, a protest in the street, cyberpunk city, a woman with pink hair and golden eyes (looking at the viewer) is holding a sign with the text "ComfyUI ControlNet Aux" in bold, neon pink" on Flux.1 Dev

The code is copy-pasted from the respective folders in https://github.com/lllyasviel/ControlNet/tree/main/annotator and connected to the 🤗 Hub.

All credit & copyright goes to https://github.com/lllyasviel.

Updates

Go to Update page to follow updates

Installation:

Using ComfyUI Manager (recommended):

Install ComfyUI Manager and do steps introduced there to install this repo.

Alternative:

If you're running on Linux, or non-admin account on windows you'll want to ensure /ComfyUI/custom_nodes and comfyui_controlnet_aux has write permissions.

There is now a install.bat you can run to install to portable if detected. Otherwise it will default to system and assume you followed ConfyUI's manual installation steps.

If you can't run install.bat (e.g. you are a Linux user). Open the CMD/Shell and do the following:

  • Navigate to your /ComfyUI/custom_nodes/ folder
  • Run git clone https://github.com/Fannovel16/comfyui_controlnet_aux/
  • Navigate to your comfyui_controlnet_aux folder
    • Portable/venv:
      • Run path/to/ComfUI/python_embeded/python.exe -s -m pip install -r requirements.txt
    • With system python
      • Run pip install -r requirements.txt
  • Start ComfyUI

Nodes

Please note that this repo only supports preprocessors making hint images (e.g. stickman, canny edge, etc). All preprocessors except Inpaint are intergrated into AIO Aux Preprocessor node. This node allow you to quickly get the preprocessor but a preprocessor's own threshold parameters won't be able to set. You need to use its node directly to set thresholds.

Nodes (sections are categories in Comfy menu)

Line Extractors

| Preprocessor Node | sd-webui-controlnet/other | ControlNet/T2I-Adapter | |-----------------------------|---------------------------|-------------------------------------------| | Binary Lines | binary | control_scribble | | Canny Edge | canny | control_v11p_sd15_canny <br> control_canny <br> t2iadapter_canny | | HED Soft-Edge Lines | hed | control_v11p_sd15_softedge <br> control_hed | | Standard Lineart | standard_lineart | control_v11p_sd15_lineart | | Realistic Lineart | lineart (or lineart_coarse if coarse is enabled) | control_v11p_sd15_lineart | | Anime Lineart | lineart_anime | control_v11p_sd15s2_lineart_anime | | Manga Lineart | lineart_anime_denoise | control_v11p_sd15s2_lineart_anime | | M-LSD Lines | mlsd | control_v11p_sd15_mlsd <br> control_mlsd | | PiDiNet Soft-Edge Lines | pidinet | control_v11p_sd15_softedge <br> control_scribble | | Scribble Lines | scribble | control_v11p_sd15_scribble <br> control_scribble | | Scribble XDoG Lines | scribble_xdog | control_v11p_sd15_scribble <br> control_scribble | | Fake Scribble Lines | scribble_hed | control_v11p_sd15_scribble <br> control_scribble | | TEED Soft-Edge Lines | teed | controlnet-sd-xl-1.0-softedge-dexined <br> control_v11p_sd15_softedge (Theoretically) | Scribble PiDiNet Lines | scribble_pidinet | control_v11p_sd15_scribble <br> control_scribble | | AnyLine Lineart | | mistoLine_fp16.safetensors <br> mistoLine_rank256 <br> control_v11p_sd15s2_lineart_anime <br> control_v11p_sd15_lineart |

Normal and Depth Estimators

| Preprocessor Node | sd-webui-controlnet/other | ControlNet/T2I-Adapter | |-----------------------------|---------------------------|-------------------------------------------| | MiDaS Depth Map | (normal) depth | control_v11f1p_sd15_depth <br> control_depth <br> t2iadapter_depth | | LeReS Depth Map | depth_leres | control_v11f1p_sd15_depth <br> control_depth <br> t2iadapter_depth | | Zoe Depth Map | depth_zoe | control_v11f1p_sd15_depth <br> control_depth <br> t2iadapter_depth | | MiDaS Normal Map | normal_map | control_normal | | BAE Normal Map | normal_bae | control_v11p_sd15_normalbae | | MeshGraphormer Hand Refiner (HandRefinder) | depth_hand_refiner | control_sd15_inpaint_depth_hand_fp16 | | Depth Anything | depth_anything | Depth-Anything | | Zoe Depth Anything <br> (Basically Zoe but the encoder is replaced with DepthAnything) | depth_anything | Depth-Anything | | Normal DSINE | | control_normal/control_v11p_sd15_normalbae | | Metric3D Depth | | control_v11f1p_sd15_depth <br> control_depth <br> t2iadapter_depth | | Metric3D Normal | | control_v11p_sd15_normalbae | | Depth Anything V2 | | Depth-Anything |

Faces and Poses Estimators

| Preprocessor Node | sd-webui-controlnet/other | ControlNet/T2I-Adapter | |-----------------------------|---------------------------|-------------------------------------------| | DWPose Estimator | dw_openpose_full | control_v11p_sd15_openpose <br> control_openpose <br> t2iadapter_openpose | | OpenPose Estimator | openpose (detect_body) <br> openpose_hand (detect_body + detect_hand) <br> openpose_faceonly (detect_face) <br> openpose_full (detect_hand + detect_body + detect_face) | control_v11p_sd15_openpose <br> control_openpose <br> t2iadapter_openpose | | MediaPipe Face Mesh | mediapipe_face | controlnet_sd21_laion_face_v2 | | Animal Estimator | animal_openpose | control_sd15_animal_openpose_fp16 |

Optical Flow Estimators

| Preprocessor Node | sd-webui-controlnet/other | ControlNet/T2I-Adapter | |-----------------------------|---------------------------|-------------------------------------------| | Unimatch Optical Flow | | DragNUWA |

How to get OpenPose-format JSON?

User-side

This workflow will save images to ComfyUI's output folder (the same location as output images). If you haven't found Save Pose Keypoints node, update this extension

Dev-side

An array of OpenPose-format JSON corresponsding to each frame in an IMAGE batch can be gotten from DWPose and OpenPose using app.nodeOutputs on the UI or /history API endpoint. JSON output from AnimalPose uses a kinda similar format to OpenPose JSON:

[
    {
        "version": "ap10k",
        "animals": [
            [[x1, y1, 1], [x2, y2, 1],..., [x17, y17, 1]],
            [[x1, y1, 1], [x2, y2, 1],..., [x17, y17, 1]],
            ...
        ],
        "canvas_height": 512,
        "canvas_width": 768
    },
    ...
]

For extension developers (e.g. Openpose editor):

const poseNodes = app.graph._nodes.filter(node => ["OpenposePreprocessor", "DWPreprocessor", "AnimalPosePreprocessor"].includes(node.type))
for (const poseNode of poseNodes) {
    const openposeResults = JSON.parse(app.nodeOutputs[poseNode.id].openpose_json[0])
    console.log(openposeResults) //An array containing Openpose JSON for each frame
}

For API users: Javascript

import fetch from "node-fetch" //Remember to add "type": "module" to "package.json"
async function main() {
    const promptId = '792c1905-ecfe-41f4-8114-83e6a4a09a9f' //Too lazy to POST /queue
    let history = await fetch(`http://127.0.0.1:8188/history/${promptId}`).then(re => re.json())
    history = history[promptId]
    const nodeOutputs = Object.values(history.outputs).filter(output => output.openpose_json)
    for (const nodeOutput of nodeOutputs) {
        const openposeResults = JSON.parse(nodeOutput.openpose_json[0])
        console.log(openposeResults) //An array containing Openpose JSON for each frame
    }
}
main()

Python

import json, urllib.request

server_address = "127.0.0.1:8188"
prompt_id = '' #Too lazy to POST /queue

def get_history(prompt_id):
    with urllib.request.urlopen("http://{}/history/{}".format(server_address, prompt_id)) as response:
        return json.loads(response.read())

history = get_history(prompt_id)[prompt_id]
for o in history['outputs']:
    for node_id in history['outputs']:
        node_output = history['outputs'][node_id]
        if 'openpose_json' in node_output:
            print(json.loads(node_output['openpose_json'][0])) #An list containing Openpose JSON for each frame

Semantic Segmentation

| Preprocessor Node | sd-webui-controlnet/other | ControlNet/T2I-Adapter | |-----------------------------|---------------------------|-------------------------------------------| | OneFormer ADE20K Segmentor | oneformer_ade20k | control_v11p_sd15_seg | | OneFormer COCO Segmentor | oneformer_coco | control_v11p_sd15_seg | | UniFormer Segmentor | segmentation |control_sd15_seg <br> control_v11p_sd15_seg|

T2IAdapter-only

| Preprocessor Node | sd-webui-controlnet/other | ControlNet/T2I-Adapter | |-----------------------------|---------------------------|-------------------------------------------| | Color Pallete | color | t2iadapter_color | | Content Shuffle | shuffle | t2iadapter_style |

Recolor

| Preprocessor Node | sd-webui-controlnet/other | ControlNet/T2I-Adapter | |-----------------------------|---------------------------|-------------------------------------------| | Image Luminance | recolor_luminance | ioclab_sd15_recolor <br> sai_xl_recolor_256lora <br> bdsqlsz_controlllite_xl_recolor_luminance | | Image Intensity | recolor_intensity | Idk. Maybe same as above? |

Examples

A picture is worth a thousand words

Testing workflow

https://github.com/Fannovel16/comfyui_controlnet_aux/blob/main/examples/ExecuteAll.png Input image: https://github.com/Fannovel16/comfyui_controlnet_aux/blob/main/examples/comfyui-controlnet-aux-logo.png

Q&A:

Why some nodes doesn't appear after I installed this repo?

This repo has a new mechanism which will skip any custom node can't be imported. If you meet this case, please create a issue on Issues tab with the log from the command line.

DWPose/AnimalPose only uses CPU so it's so slow. How can I make it use GPU?

There are two ways to speed-up DWPose: using TorchScript checkpoints (.torchscript.pt) checkpoints or ONNXRuntime (.onnx). TorchScript way is little bit slower than ONNXRuntime but doesn't require any additional library and still way way faster than CPU.

A torchscript bbox detector is compatiable with an onnx pose estimator and vice versa.

TorchScript

Set bbox_detector and pose_estimator according to this picture. You can try other bbox detector endings with .torchscript.pt to reduce bbox detection time if input images are ideal.

ONNXRuntime

If onnxruntime is installed successfully and the checkpoint used endings with .onnx, it will replace default cv2 backend to take advantage of GPU. Note that if you are using NVidia card, this method currently can only works on CUDA 11.8 (ComfyUI_windows_portable_nvidia_cu118_or_cpu.7z) unless you compile onnxruntime yourself.

  1. Know your onnxruntime build:
    • NVidia CUDA 11.x or bellow/AMD GPU: onnxruntime-gpu
    • NVidia CUDA 12.x: onnxruntime-gpu --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/
    • DirectML: onnxruntime-directml
    • OpenVINO: onnxruntime-openvino

Note that if this is your first time using ComfyUI, please test if it can run on your device before doing next steps.

  1. Add it into requirements.txt

  2. Run install.bat or pip command mentioned in Installation

Assets files of preprocessors

2000 Stars 😄

<a href="https://star-history.com/#Fannovel16/comfyui_controlnet_aux&Date"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Fannovel16/comfyui_controlnet_aux&type=Date&theme=dark" /> <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Fannovel16/comfyui_controlnet_aux&type=Date" /> <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Fannovel16/comfyui_controlnet_aux&type=Date" /> </picture> </a>

Thanks for yalls supports. I never thought the graph for stars would be linear lol.