Comfy-Org/ComfyUI · error · ValueError
Number of positive conditions ({len(positive)}) does not mat
Error message
Number of positive conditions ({len(positive)}) does not match number of images ({num_images}). What it means
In the training-node conditioning validation helper, when bucket_mode is off, the number of positive conditions must equal the number of training images (a single condition may be broadcast to all images). Any other count mismatch raises this error so the trainer does not silently pair images with the wrong captions.
Source
Thrown at comfy_extras/nodes_train.py:669
Args:
positive: Conditioning list
num_images: Number of images
bucket_mode: Whether bucket mode is enabled
Returns:
Validated/expanded conditioning list
Raises:
ValueError: If conditioning count doesn't match image count
"""
if bucket_mode:
return positive # Skip validation in bucket mode
logging.debug(f"Total Images: {num_images}, Total Captions: {len(positive)}")
if len(positive) == 1 and num_images > 1:
return positive * num_images
elif len(positive) != num_images:
raise ValueError(
f"Number of positive conditions ({len(positive)}) does not match number of images ({num_images})."
)
return positive
def _load_existing_lora(existing_lora):
"""Load existing LoRA weights if provided.
Args:
existing_lora: LoRA filename or "[None]"
Returns:
tuple: (existing_weights dict, existing_steps int)
"""
if existing_lora == "[None]":
return {}, 0
lora_path = folder_paths.get_full_path_or_raise("loras", existing_lora)View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Make the number of positive conditions match the number of images exactly, or supply exactly one condition to broadcast
- Audit the caption list for missing/extra entries relative to the image dataset
- If the mismatch is intentional and buckets handle grouping, enable bucket_mode which skips this validation
Example fix
# before: 8 images, 3 captions positive = [c1, c2, c3] # after: one caption broadcast to all images positive = [c1] * 8 # or exactly 8 caption entries
Defensive patterns
Strategy: validation
Validate before calling
if not bucket_mode:
if len(positive) == 1:
positive = positive * num_images
elif len(positive) != num_images:
raise ValueError(f"captions={len(positive)} images={num_images}") Prevention
- Write dataset prep scripts that assert caption count == image count before training
- Remember exactly one caption broadcasts; any other count must match
When it happens
Trigger: Calling the training node with, say, 8 images and 3 positive conditioning entries (and not exactly 1), with bucket_mode disabled. Bucket mode skips the check entirely and returns the list unchanged.
Common situations: Caption folder has a different file count than the image folder; some images failed to load upstream changing num_images; a batch-size or dataloader change desynchronized captions from images; user assumed captions broadcast but supplied 2+ entries.
Related errors
- Need at least {require_count} hooks to combine, but only had
- PixDiT_T2I requires context (text embeddings) of shape [B, L
- PidNet requires lq_latent — attach via PiDConditioning
- SeedVR2 expected an even text-conditioning batch, got shape
- SeedVR2 expected {name} channels to be {channels}, got shape
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/1b563f0e3aacd867.
Report an issue: GitHub.