CoachBate H3 Subject Count
How many subjects are in this clip? Ask before you queue, not after
- images
- subjects
- report
A counter that drives a loop
CoachBate H3 Subject Count answers one question - how many subjects does this clip show? - and the
answer is meant to be wired into Pixaroma's Loop Start total, so that a full H3 subject-refine
pass runs once per subject. One subject, one render. That's the "Refine xN" blueprint in the
README, and this node is its head.
It runs your YOLO detector over sampled frames (images in, detector + confidence +
sample_every out of the way) and returns subjects (INT) plus a report string.
Why it's not just "max detections"
Naively, the count is the busiest frame's detection count. That's a trap, because a single-frame
false positive then buys you an entire extra H3 render of the whole clip. So the node asks for the
largest per-frame count that holds on at least min_fraction of the sampled frames - default
0.05, i.e. 5%. A blob that appears in one frame out of a hundred doesn't count. max_subjects
(default 20) is the hard cap, and since each subject is a full render of the clip, max_subjects = 1 is a legitimate way to force a single pass on a video you know has one subject and a noisy
detector.
sample_every (default 1) detects on every nth frame. For a long clip where you just want the
subject count, 4 or 8 is plenty and it's the cheapest way to make this node disappear from your
runtime. detector should be the same detector the tracker uses - same weights, same idea of what
a subject is - otherwise you can count three and fail to track the third.
Inputs and outputs
images- the clip.detector- a YOLO model registered frommodels/ultralytics/segm(orbbox). This is the same dropdown the tracker offers, fed by Impact-Subpack's folder registration, or by the pack's own direct folder lookup if the Subpack isn't installed.confidence(default 0.3),sample_every,min_fraction,max_subjectsas above.
Outputs: subjects (INT) and report. The report is where you find the per-frame counts, which
is how you tell "the detector sees two people" from "the detector occasionally thinks a lamp is a
person".
Install
cd ComfyUI/custom_nodes
git clone https://github.com/CoachBate/ComfyUI-CoachBate.git
Or ComfyUI Manager → "CoachBate" → restart. It appears under CoachBate / H3. Requires
ultralytics to be installed; weights go in models/ultralytics/segm/.
Where people get burned
- An extra render pass you didn't want.
min_fractionis doing its job badly - raise it to 0.15 or so, or cap withmax_subjects. - The count is lower than you expected. Two subjects standing close together may be merged
into one detection, or
confidenceis high enough to drop the smaller one. Check thereportrather than guessing. - Counts change between runs of the same clip.
sample_everyis skipping the frames where the second subject appears. Set it to 1 for the final count.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| detector | COMBO | The same detector the tracker uses. | |
| confidence | FLOAT | 0.300.05–0.95 | — |
| sample_every | INT | 11–60 | Detect on every nth frame. 1 = every frame. |
| min_fraction | FLOAT | 0.050.01–1 | A count must appear on at least this fraction of the sampled frames to be believed, so a single-frame false positive does not add a whole extra render pass. |
| max_subjects | INT | 201–50 | Cap. Each subject is a full H3 render of the clip. 1 forces a single pass. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| subjects | INT | — |
| report | STRING | — |