Nodes/ComfyUI-Pt-Wrapper/Pt Bool Create
ComfyUI Node

Pt Bool Create

Hand-type a boolean tensor and get on with it

By HowToSD·Created about a year ago·Updated about a year ago· 7
Pt Bool Create
    • TENSOR
    data

    Sometimes you just need a mask, and building one with a slider feels like overkill. Pt Bool Create is the pack's "I have a specific boolean list in mind" node: you type a Python list literal into a text box, and it becomes a 1D boolean tensor. Type [True, False, False, True], get a torch.bool tensor of [True, False, False, True]. That's the whole job, and it's genuinely convenient when you're feeding masks into PtMaskedSelect, PtWhere, or a comparison chain.

    Under the hood it's exactly what you'd write by hand: the text is parsed with Python's ast.literal_eval (safe - no arbitrary code, just literals), then torch.tensor(list_data, dtype=torch.bool). The multiline text field is there so you can write a long mask across several lines without fighting the single-line input.

    The one input

    • data - a STRING (multiline) holding a Python list literal of True/False. It must be valid Python - square brackets, commas, correct spelling. [true, false] (lowercase) will throw; Python is case-sensitive.

    Output: a TENSOR with dtype bool, one element per entry.

    The gotchas, which are mostly about typing

    Three things bite people. One: it must be a full list literal - True, False without brackets fails literal_eval. Two: the values must be actual Python True/False; 1/0 work too since they're literals, but they'll be coerced to bool, which surprises people who expected an int tensor. Three: a trailing comma is fine, a stray typo is not - the error message from literal_eval will name the exact spot, so it's usually quick to fix.

    Where does this fit in the pack's world? It's a tensor-creation node, sibling to PtIntCreate and PtFloatCreate, and it exists because the author's training workflows need masks and labels built by hand. If your boolean data already exists as a tensor somewhere, this is redundant - but for a quick hand-authored mask, it's the least fiddly option in the pack.

    Installing it

    Part of ComfyUI-Pt-Wrapper (Hide Inada / HowToSD). Install via ComfyUI Manager (search "ComfyUI-Pt-Wrapper") and restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
    

    Heads-up on dependencies: the pack pulls in scipy, scikit-learn, transformers, datasets, gensim, pandas, peft, accelerate and more. If the auto-install fails, pip install -r requirements.txt inside the clone. No model downloads for this node.

    CategoryData Analysis

    Inputs (1)

    NameTypeDefaultDescription
    dataSTRING

    Outputs (1)

    NameTypeDescription
    TENSORTENSOR