Doom Index Pair Counter
Pairing a main image set with a style set
- index_main
- index_style
- status
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 everycount_mainsteps.
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_mainandcount_styleagainst 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. indexstarting 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 -
indexis 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.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| index | INT | 0 | Внешний счётчик (обычно от DoomRandomPrompt или вручную) |
| count_main | INT | 1 | Количество файлов в основной папке |
| count_style | INT | 1 | Количество файлов в папке стилей |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| index_main | INT | Индекс в основной папке |
| index_style | INT | Индекс в папке стилей |
| status | STRING | Текстовая сводка состояния |