Nodes/Doom_Flux_NodePack/Doom Index Pair Counter
ComfyUI Node

Doom Index Pair Counter

Pairing a main image set with a style set

By PeterMikhai·Created about a year ago·Updated 6 days ago· 1
Doom Index Pair Counter
    • index_main
    • index_style
    • status
    index0
    count_main1
    count_style1

    Doom Index Pair Counter is a small piece of batch math, and its reason for existing is one very specific and very common workflow: you have two folders - a folder of main images and a folder of styles (or references, or LoRA presets) - and you want every combination of main × style, exactly once, without writing a loop in your head.

    It takes a single index and turns it into two indices: index_main cycles through folder A, and index_style advances every time folder A wraps around. Feed it the pack's DoomImageLoader (or any counter) and it keeps the two streams in the right lockstep.

    How it works

    The math is two lines and it's worth understanding because it explains everything:

    • index_main = index % count_main - main cycles 0..count_main-1, wrapping each time.
    • index_style = (index // count_main) % count_style - style advances by one every count_main steps.

    So with count_main = 4 and count_style = 3, the sequence looks like:

    index 0: main 0, style 0
    index 1: main 1, style 0
    index 2: main 2, style 0
    index 3: main 3, style 0
    index 4: main 0, style 1   <- main wraps, style advances
    index 5: main 1, style 1
    ...
    

    That's the classic cross-product enumeration: every main image gets paired with style 0, then style 1, and so on, until you've covered main×style. count_main and count_style are just the sizes of your two folders.

    Inputs: index (the external counter - the tooltip suggests DoomRandomPrompt or manual), count_main, count_style. Outputs: index_main, index_style (both INT), and status, a string like index=7 | main=3/4 | style=1/3 that tells you exactly where you are - handy to pipe into a text display while a batch runs.

    Why you'd reach for it

    The pack's own DoomImageLoader has dual A/B streams, but those advance independently. When the pairing has a strict relationship - "every main image through every style" - you want one counter driving both, and this is that node. It slots in wherever an index needs to be decomposed into a pair: style transfer batches, character × background sweeps, LoRA × prompt grids.

    Installing it

    cd ComfyUI/custom_nodes
    git clone https://github.com/PeterMikhai/Doom_Flux_NodePack
    

    Restart or ComfyUI Manager. No extra deps; current ComfyUI. README's DoomAI_nodes.git line is stale - repo is Doom_Flux_NodePack.

    Common issues

    • "The pairing isn't what I expected." Check count_main and count_style against your actual folder sizes. If you set count_main to 10 but the folder has 8 files, style advances at the wrong cadence and you'll revisit images or skip pairs. Measure the folder, then set the count.
    • index starting above 0 - the node doesn't care; it's pure modular arithmetic, so a counter that resumes at 500 picks up mid-sequence correctly. That's a feature: you can resume an interrupted batch.
    • Overflow on huge counts - index is an INT (unsigned up to ~1.8e19), and // is integer division, so this is exact arithmetic; no floating drift to worry about at any realistic batch size.

    It's a three-line idea packaged as a node, but three-line ideas are exactly what batch workflows are built from - and this one gets the pairing right the first time.

    CategoryDoom/Utils

    Inputs (3)

    NameTypeDefaultDescription
    indexINT0Внешний счётчик (обычно от DoomRandomPrompt или вручную)
    count_mainINT1Количество файлов в основной папке
    count_styleINT1Количество файлов в папке стилей

    Outputs (3)

    NameTypeDescription
    index_mainINTИндекс в основной папке
    index_styleINTИндекс в папке стилей
    statusSTRINGТекстовая сводка состояния