invoke-ai/InvokeAI · error · ValueError
At least one Krea-2 text conditioning is required.
Error message
At least one Krea-2 text conditioning is required.
What it means
Krea2RegionalPromptingExtension.from_text_conditionings assembles concatenated embeddings and embedding ranges from the supplied text conditionings. With an empty list there is nothing to build a regional layout from, so it raises ValueError immediately.
Source
Thrown at invokeai/backend/krea2/regional_prompting.py:54
def attention_mask_numel(self) -> int:
if not self.has_regional_masks:
return 0
total_seq_len = self.regional_text_conditioning.prompt_embeds.shape[1] + self.image_seq_len
return total_seq_len**2
@property
def attention_mask_build_scratch_numel(self) -> int:
"""Peak boolean scratch allocation used while constructing the image-to-image attention block."""
if not self.has_regional_masks:
return 0
return self.image_seq_len**2
@classmethod
def from_text_conditionings(
cls, text_conditionings: list[Krea2TextConditioning], image_seq_len: int
) -> "Krea2RegionalPromptingExtension":
if not text_conditionings:
raise ValueError("At least one Krea-2 text conditioning is required.")
prompt_embeds: list[torch.Tensor] = []
image_masks: list[torch.Tensor | None] = []
embedding_ranges: list[Range] = []
current_start = 0
for conditioning in text_conditionings:
sequence_length = conditioning.prompt_embeds.shape[1]
if conditioning.mask is not None and conditioning.mask.numel() != image_seq_len:
raise ValueError(
f"Krea-2 regional mask has {conditioning.mask.numel()} values, expected {image_seq_len}."
)
prompt_embeds.append(conditioning.prompt_embeds)
image_masks.append(conditioning.mask)
embedding_ranges.append(Range(start=current_start, end=current_start + sequence_length))
current_start += sequence_length
regional_text_conditioning = Krea2RegionalTextConditioning(
prompt_embeds=torch.cat(prompt_embeds, dim=1),View on GitHub (pinned to 0b6a024f2f)
Solutions
- Ensure at least one Krea2TextConditioning (typically the global/base prompt) is passed.
- Check upstream code that filters or splits prompts into regional conditionings and fix the empty-list case.
- Disable regional prompting if you only have a single non-regional prompt.
- Assert len(text_conditionings) > 0 before calling the classmethod.
Example fix
// before
ext = Krea2RegionalPromptingExtension.from_text_conditionings(regions, image_seq_len) # regions == []
// after
if not regions:
regions = [default_text_conditioning]
ext = Krea2RegionalPromptingExtension.from_text_conditionings(regions, image_seq_len) Defensive patterns
Strategy: validation
Validate before calling
if not text_conditionings:
raise ValueError('Regional prompting enabled but no text conditionings provided; add at least the base prompt')
ext = Krea2RegionalPromptingExtension.from_text_conditionings(text_conditionings, image_seq_len) Type guard
def can_build_regional_extension(conds) -> bool:
return isinstance(conds, (list, tuple)) and len(conds) > 0 Try / catch
try:
ext = Krea2RegionalPromptingExtension.from_text_conditionings(conds, image_seq_len)
except ValueError as e:
if 'At least one Krea-2 text conditioning' in str(e):
ext = None # fall back to non-regional generation
else:
raise Prevention
- Always include the global/base prompt as the first conditioning
- Check the regional-prompt extraction step for silent empty results
- Skip regional prompting entirely when there is only one prompt
- Unit-test the prompt-splitting path to never emit an empty list
When it happens
Trigger: Calling from_text_conditionings([], image_seq_len=N) — e.g. the regional-prompting path was enabled but regional prompt extraction produced zero conditionings, or a filter dropped all conditionings before this call.
Common situations: Regional prompting toggle enabled with no regional prompts defined; a bug upstream that skips adding the base conditioning; passing an empty slice of conditionings.
Related errors
- per_layer_weights must be comma-separated numbers: {e}
- per_layer_weights must have exactly {_NUM_TEXT_LAYERS} value
- per_layer_weights must contain only finite values.
- cfg_scale values must be finite.
- shift must be finite.
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/de57559fba717fd1.
Report an issue: GitHub.