lllyasviel/Fooocus · error · ValueError
Unsupported blend mode: {mode}
Error message
Unsupported blend mode: {mode} What it means
The image-space Blend node (external_post_processing) supports exactly six modes — normal, multiply, screen, overlay, soft_light, difference — and raises ValueError for anything else. The string comparison is exact/lowercase, so casing or whitespace breaks it. Note 'soft_light' uses an underscore, not a hyphen.
Source
Thrown at ldm_patched/contrib/external_post_processing.py:63
blended_image = image1 * (1 - blend_factor) + blended_image * blend_factor
blended_image = torch.clamp(blended_image, 0, 1)
return (blended_image,)
def blend_mode(self, img1, img2, mode):
if mode == "normal":
return img2
elif mode == "multiply":
return img1 * img2
elif mode == "screen":
return 1 - (1 - img1) * (1 - img2)
elif mode == "overlay":
return torch.where(img1 <= 0.5, 2 * img1 * img2, 1 - 2 * (1 - img1) * (1 - img2))
elif mode == "soft_light":
return torch.where(img2 <= 0.5, img1 - (1 - 2 * img2) * img1 * (1 - img1), img1 + (2 * img2 - 1) * (self.g(img1) - img1))
elif mode == "difference":
return img1 - img2
else:
raise ValueError(f"Unsupported blend mode: {mode}")
def g(self, x):
return torch.where(x <= 0.25, ((16 * x - 12) * x + 4) * x, torch.sqrt(x))
def gaussian_kernel(kernel_size: int, sigma: float, device=None):
x, y = torch.meshgrid(torch.linspace(-1, 1, kernel_size, device=device), torch.linspace(-1, 1, kernel_size, device=device), indexing="ij")
d = torch.sqrt(x * x + y * y)
g = torch.exp(-(d * d) / (2.0 * sigma * sigma))
return g / g.sum()
class Blur:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(s):
return {
"required": {View on GitHub (pinned to ae05379cc9)
Solutions
- Use one of: 'normal', 'multiply', 'screen', 'overlay', 'soft_light', 'difference'.
- Normalize input: mode = mode.strip().lower() before calling if user-supplied.
- Validate mode against the allowed set in your UI/schema before queueing the job.
- For unsupported modes like 'add', compute manually: img1 + img2 (clamped).
Example fix
# before out = blend.blend_images(a, b, mode='soft-light') # ValueError # after out = blend.blend_images(a, b, mode='soft_light')
Defensive patterns
Strategy: validation
Validate before calling
BLEND_MODES = {'normal', 'multiply', 'screen', 'overlay', 'soft_light', 'difference'}
mode = mode.strip().lower()
if mode not in BLEND_MODES:
raise ValueError(f'mode must be one of {sorted(BLEND_MODES)}, got {mode!r}') Type guard
def is_supported_blend_mode(mode: str) -> bool:
return isinstance(mode, str) and mode.strip().lower() in {'normal', 'multiply', 'screen', 'overlay', 'soft_light', 'difference'} Try / catch
try:
out = blend.blend_images(img1, img2, mode)
except ValueError as e:
if 'blend mode' in str(e):
raise ValueError(f'{mode!r} unsupported; allowed: normal/multiply/screen/overlay/soft_light/difference') from e
raise Prevention
- Constrain UI dropdowns and JSON schemas to the six supported mode strings.
- Normalize (strip + lower) user-supplied mode strings before use.
- Remember the underscore form 'soft_light', not 'soft-light'.
When it happens
Trigger: Calling Blend.blend_images(img1, img2, mode=...) with values like 'add', 'lighten', 'soft-light', 'Soft_Light', or ' multiply' (leading space).
Common situations: Porting mode names from Photoshop/GIMP (which include 'lighten', 'color-dodge', etc.), typos from hand-edited workflow JSONs, or hyphen/underscore confusion between libraries.
Related errors
AI-assisted analysis of lllyasviel/Fooocus@ae05379cc9 (2026-08-15).
Data as JSON: /api/errors/3433039eb71f7097.
Report an issue: GitHub.