Nodes/comfyui_cv/CV Text To Array
ComfyUI Node

CV Text To Array

Splits typed text into an (N,) array of STRINGS - the form the pack's caption inputs take ('CV Draw Labels'.labels), and the same thing a QR/barcode detector's `texts` output or 'CV Load Labels'.labels_array already produces. Use it to name a handful of things by hand: annotation anchors, class names for a small classifier, legend entries. 'CV Numbers To Array' is the numeric counterpart (it parses the same text into floats/ints instead) and 'CV Array To Text' is the inverse. Entries keep their order and their count, so an array of N labels lines up one-for-one with N points - which is what every consumer assumes.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Text To Array
    • nparray
    • count
    text
    separatorone per line
    keep_emptyfalse
    Categoryimage/CV/low-level

    Inputs (3)

    NameTypeDefaultDescription
    textSTRINGThe entries to split, one per line by default. Blank lines are dropped, so a trailing newline is harmless; surrounding whitespace on each entry is trimmed. Empty text gives an empty array, not an error.
    separatorCOMBOone per lineHow to cut the text into entries. 'one per line' is the safest for captions - it is the only option that lets an entry contain spaces AND commas. Pick 'comma' for a list pasted from a CSV header, 'whitespace' for single-word tokens.
    keep_emptyoptBOOLEANfalseKeep entries that are empty after trimming. Off drops them, which is what you want when the text was typed by hand. Turn it ON when the entries must stay aligned with a fixed-length list and a blank line means 'no caption for this one'.

    Outputs (2)

    NameTypeDescription
    nparrayNPARRAY(N,) numpy array of strings (dtype '<U'). Wire it into 'CV Draw Labels'.labels, or anywhere a detector's `texts` output would go.
    countINTHow many entries were produced. Check it against the number of points you are labelling - the drawing nodes reject a mismatch rather than silently labelling the wrong ones.