Add validation to prevent empty prompts causing tokenization errors

Co-authored-by: jags111 <5968619+jags111@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-03 23:01:19 +00:00
parent f9692f29ff
commit b083ff3f6c
4 changed files with 14 additions and 0 deletions

View File

@@ -72,6 +72,12 @@ def encode_prompts(positive_prompt, negative_prompt, token_normalization, weight
refiner_clip, refiner_clip_skip, ascore, is_sdxl, empty_latent_width, empty_latent_height,
return_type="both"):
# Ensure prompts are valid strings to prevent tokenization errors
if positive_prompt is None or (isinstance(positive_prompt, str) and not positive_prompt.strip()):
positive_prompt = " "
if negative_prompt is None or (isinstance(negative_prompt, str) and not negative_prompt.strip()):
negative_prompt = " "
positive_encoded = negative_encoded = refiner_positive_encoded = refiner_negative_encoded = None
# Process base encodings if needed