Nodes/KJNodes for ComfyUI/CreateInstanceDiffusionTracking
ComfyUI Node Runs on cloud

CreateInstanceDiffusionTracking

Per-object prompts via bounding boxes

By kijai·Created 3 years ago·Updated a day ago· 2,908
CreateInstanceDiffusionTracking
    • tracking
    • prompt
    • width
    • height
    • bbox_width
    • bbox_height
    coordinates
    width512
    height512
    bbox_width512
    bbox_height512
    class_nameclass_name
    class_id0
    promptprompt
    size_multiplier1
    fit_in_frametrue

    Regional prompting - giving different areas of an image different prompts - usually means drawing rough masks and hoping the model respects the boundary. InstanceDiffusion is a more surgical version of the same idea: instead of a soft mask, you give it an exact bounding box, a class label, and a prompt for that specific instance. This node is how you build one of those box-and-prompt entries inside ComfyUI, for use with logtd's ComfyUI-InstanceDiffusion - a separate, third-party node pack this one is explicitly built to feed.

    The format, straight from the node

    The node's own description spells out exactly how InstanceDiffusion expects instance data to look: "class_id.class_name": "prompt", for example "1.head": "((head))". This node builds one of those entries: you're telling it which box on the canvas, what class it belongs to, and what prompt should apply only inside that box.

    The inputs that matter

    • coordinates (STRING, required) - the box/track coordinates, in InstanceDiffusion's own coordinate syntax. This node doesn't validate the format for you - get the syntax wrong and the failure shows up downstream, in the actual InstanceDiffusion sampler node, not here.
    • width / height (default 512) - the canvas dimensions this box is defined against.
    • bbox_width / bbox_height (default 512) - the size of this specific instance's box.
    • class_name (default "class_name") and class_id (default 0) - together these form the key half of the "class_id.class_name" pair. They need to match exactly what your prompt keys expect downstream.
    • prompt (multiline STRING) - the text that applies only to this instance's box.
    • Optional size_multiplier (FLOAT, default [1] - accepts a list, which suggests per-frame scaling for video use) and fit_in_frame (default true, clamps the box so it can't extend past canvas bounds).

    Outputs: tracking (the TRACKING object you wire onward), plus prompt, width, height, bbox_width, bbox_height passed straight through - convenient for feeding the same numbers into other nodes downstream, or keeping multiple Create/Append nodes in a chain agreeing on canvas size without retyping values.

    How to install it

    The KJNodes half via ComfyUI Manager (search KJNodes for ComfyUI) or manually:

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

    But this node alone does nothing useful - the TRACKING output only means something once it reaches an actual InstanceDiffusion sampling node. You need logtd/ComfyUI-InstanceDiffusion installed alongside KJNodes for any of this to render anything.

    Common issues & troubleshooting

    This is a deep-cut integration, not a mainstream one. A quick check of real community discussion around InstanceDiffusion in ComfyUI shows a short cluster of activity in early 2024 and essentially nothing since - it's a real, working integration, but not one with an active current community you can lean on if something breaks. Expect to read the linked repos directly rather than find a fresh thread with your exact error.

    Nothing shows up in the render, no error anywhere. Check that class_id and class_name here match a key your prompt actually references downstream - a mismatched class key is a silent no-op, not a crash, because this node doesn't cross-validate against anything else in your graph.

    Multiple instances aren't combining. This node only creates one tracking entry. You need AppendInstanceDiffusionTracking to merge two of them together, chained if you have more than two subjects.

    You just want regional prompting, not per-object detection-style control. This is the fiddlier, more surgical tool. If a soft mask per region is enough, this pack's ConditioningSetMaskAndCombine family is the more common, lower-effort path to the same broad goal.

    CategoryKJNodes/InstanceDiffusion

    Inputs (10)

    NameTypeDefaultDescription
    coordinatesSTRING
    widthINT51216–4096
    heightINT51216–4096
    bbox_widthINT51216–4096
    bbox_heightINT51216–4096
    class_nameSTRINGclass_name
    class_idINT00–255
    promptSTRINGprompt
    size_multiplieroptFLOAT1
    fit_in_frameoptBOOLEANtrue

    Outputs (6)

    NameTypeDescription
    trackingTRACKING
    promptSTRING
    widthINT
    heightINT
    bbox_widthINT
    bbox_heightINT