Nodes/CMK Flow/CMK ControlNet Prepare
ComfyUI Node

CMK ControlNet Prepare

ControlNet prep without a single extra node pack — and what that costs you

By CMKFlow·Created 3 months ago·Updated a day ago· 6
CMK ControlNet Prepare
  • opt_base_image
  • opt_mask
  • control_net
  • controlnet_image
  • controlnet_enabled
  • controlnet_prepare_log
  • diagnostic
◄USE CONTROLNETfalse►
◄controlnet_model▾►
◄image_sourceBase Image►
◄reference_image►
◄apply_maskfalse►
◄preprocessorLineArtPreprocessor►
◄resolution768►

ControlNet in ComfyUI normally means installing ComfyUI-ControlNet-Aux, downloading a couple of gigabytes of annotator models, and discovering that your transformers version now breaks something else. CMK ControlNet Prepare does the loading, the source selection and the preprocessing in one node with zero external packs. That's a real convenience, and the reason it works is also the catch.

What it is

A standalone toolbox node - CMK/Toolbox/ControlNet - that takes an image and hands you a loaded CONTROL_NET plus the processed conditioning image, ready for the core ControlNetApplyAdvanced or for the pack's own sampler module. It's the open-box sibling of the -Pipe- version, and it's the one to reach for if you're not running CMK's modular pipeline.

How it works

You set USE CONTROLNET, pick a controlnet_model from models/controlnet, choose where the conditioning image comes from, and pick a preprocessor. Then:

  • image_source Base Image → it uses whatever you wired into opt_base_image.
  • image_source Reference Image → it loads the file named in the reference_image text field, resolved against ComfyUI's input directory, with full EXIF-transpose and multi-frame handling.
  • apply_mask multiplies the source by opt_mask before preprocessing, so you can condition on a region only.

Now the part you should actually know about. The preprocessors are CMK's own OpenCV implementations, not the ControlNet Aux annotator models. There is no controlnet_aux import anywhere in the pack. Read the code and the dropdown roughly resolves to three real behaviours:

  • canny runs a genuine cv2.Canny at 100/200.
  • tile and shuffle pass your RGB through essentially unchanged.
  • depth_midas / depth_zoe produce an inverted blurred greyscale - a depth-ish ramp, not MiDaS or ZoeDepth.
  • normalbae synthesises a Sobel-based pseudo-normal map.
  • Everything else in the list - lineart, lineart_coarse, lineart_realistic, softedge_hed, softedge_pidinet, openpose, dwpose, mlsd, scribble - lands in one shared fallback: a bilateral filter plus Canny at 48/144, with scribble binarised. The default LineArtPreprocessor is in this bucket.

So: pick canny, tile, shuffle, or none and you get exactly what the name promises. Pick openpose expecting a pose skeleton and you get an edge map. That's not a bug being hidden - the log line says CMK native preprocessor applied - but it is the thing that will confuse you if you don't know it. For real depth, pose or lineart annotation, install ControlNet Aux alongside and preprocess there.

The resolution widget is also effectively decorative: it's clamped, logged, and then explicitly discarded before the preprocessor call. Don't tune it expecting a change.

Outputs are control_net (the loaded model - None when disabled or when the model name is empty), controlnet_image, controlnet_enabled, a controlnet_prepare_log string, and a diagnostic. The node is an output node, so it previews the processed conditioning image in the temp directory while it runs; when it's disabled it writes a 1×1 transparent placeholder instead, so a stale preview can't mislead you into thinking ControlNet fired.

Install

Manager: search CMK Flow, install the CMKFlow entry, restart. Manual:

git clone https://github.com/CMKFlow/cmk_nodes.git custom_nodes/cmk_nodes
python3 custom_nodes/cmk_nodes/scripts/install_cmk_requirements.py

(CMK dependency check: OK = done.) The Python dependencies are the chunky kind - ultralytics, onnxruntime, insightface, segment-anything, opencv-python, nudenet==3.4.2 - because the pack installs as one unit, including the detailer and face-swap machinery. opencv-python is what this node actually uses. ControlNet models themselves aren't part of the package; drop them in models/controlnet or point the resource check at a shared folder:

python3 custom_nodes/cmk_nodes/scripts/check_cmk_resources.py --models-root "/path/to/shared/models"

Issues worth knowing

Empty controlnet_model doesn't raise - the node returns controlnet_enabled = False and a log line saying the model was missing, and the conditioning image still comes through. Check that output if your ControlNet seems to have no effect.

The reference_image field is a bare string here; the -Pipe- version turns it into a dropdown of files from your input directory plus a packaged sample, which is easier to live with. And USE CONTROLNET off means no model load and no preprocessing at all - which is the point, and also why an unwired reference image can sit there looking connected and never bother you until you flip the switch.

CategoryCMK/Toolbox/ControlNet

Inputs (9)

NameTypeDefaultDescription
USE CONTROLNETBOOLEANfalse—
controlnet_modelCOMBO1 options:
image_sourceCOMBOBase Image2 options: Base Image, Reference Image
reference_imageSTRING—
apply_maskBOOLEANfalse—
preprocessorCOMBOLineArtPreprocessor18 options: LineArtPreprocessor, none, canny, lineart, lineart_coarse, lineart_realistic, +12
resolutionINT76864–8192—
opt_base_imageoptIMAGE—
opt_maskoptMASK—

Outputs (5)

NameTypeDescription
control_netCONTROL_NET—
controlnet_imageIMAGE—
controlnet_enabledBOOLEAN—
controlnet_prepare_logSTRING—
diagnosticCMK_DIAGNOSTIC—