Nodes/XBHH Live2D Pet & LoRA/xbhh 空Latent 📐
ComfyUI Node

xbhh 空Latent 📐

The empty latent node that stops you doing aspect-ratio math in your head

By xbhh123456·Created 8 months ago·Updated about a month ago· 13
xbhh 空Latent 📐
    • latent
    • width
    • height
    resolution1024x1024 (1:1)
    batch_size1
    custom_width1024
    custom_height1024

    Every ComfyUI graph that starts from noise needs an empty latent - the blank canvas that the sampler denoises into an image. Stock ComfyUI gives you the bare-bones EmptyLatentImage with one width, one height, one batch size, and no guardrails. This node from the XBHH kit replaces it with a dropdown of 16 common resolutions, auto-aligns everything to multiples of 8, and passes the width and height out as numbers so the rest of your graph can use them. If you build workflows from scratch rather than only editing downloaded ones, this is a genuine quality-of-life upgrade.

    How it works

    Diffusion models don't sample at pixel resolution - they work in a latent space that's 8× smaller per side. A 1024×1024 image is a 1×4×128×128 tensor under the hood. That's why a latent's dimensions must be divisible by 8: a non-multiple silently produces a sampler error or a silently mis-sized output, depending on the model. This node enforces the rule for you.

    Pick a preset from the resolution dropdown and the node creates the matching blank latent with torch.zeros. The catch-all 自定义 (custom) option hands control to custom_width and custom_height instead, both stepping by 8 and clamped to 8192 - so even the custom path can't produce an unaligned size. It floors to a multiple of 8 rather than rounding up, which matters if you're pedantic about exact dimensions.

    The inputs and outputs that matter

    • resolution - the dropdown. The presets cover the boring canonical set (512/768/1024 squares, the 2:3 and 3:4 portrait/landscape pairs, 9:16 and 16:9) plus the SD1.5 and SDXL sweet spots (832×1216, 896×1152, and friends) and 自定义. Default is 1024x1024 (1:1), which is the right default for SDXL-and-up.
    • batch_size - 1 to 64. Raise it when you want the sampler to produce N images in one pass from one latent.
    • custom_width / custom_height (optional) - only read when resolution is 自定义. Step of 8, max 8192.

    Three outputs: latent (the LATENT you wire into the KSampler's latent_image port), plus width and height as integers. That pair is the sleeper feature - you can route them into conditioning or image-size math elsewhere in the graph, so one node both sets the canvas and tells the rest of the workflow what it chose.

    Installing it

    It ships inside the XBHH kit, so install is the pack-level one:

    cd ComfyUI/custom_nodes
    git clone https://github.com/xbhh123456/Comfyui-xbhh-main.git
    cd Comfyui-xbhh-main
    pip install -r requirements.txt
    

    Or ComfyUI Manager, search xbhh-lora, restart. No models, no downloads beyond the kit itself - the only real dependency is openpyxl for the unrelated Excel viewer.

    The catch worth knowing

    For most people this node is simply the stock empty latent with training wheels, and that's the whole point. The one thing to keep in mind: pick a resolution that matches your checkpoint family. The SD1.5 presets (832×1216) are wasted on an SDXL model and vice versa - the preset names encode which architecture they're meant for, and the model doesn't care that you chose it, it just samples at the size you gave it. If you're doing img2img or hires-fix, feeding this node's latent into a workflow that expects a specific size is where people get confused; check the width/height outputs against what the rest of the graph assumes.

    CategoryXBHH

    Inputs (4)

    NameTypeDefaultDescription
    resolutionCOMBO1024x1024 (1:1)16 options: 512x512 (1:1), 768x768 (1:1), 1024x1024 (1:1), 512x768 (2:3), 768x512 (3:2), 512x896 (9:16), +10
    batch_sizeINT11–64
    custom_widthoptINT102464–8192
    custom_heightoptINT102464–8192

    Outputs (3)

    NameTypeDescription
    latentLATENT
    widthINT
    heightINT