lllyasviel/Fooocus · error · NotImplementedError

activation layer [{:s}] is not found

Error message

activation layer [{:s}] is not found

What it means

block.act() is the activation factory for the BasicSR-derived blocks (used by RRDB/SPSR/etc. conv blocks). After lowercasing, it knows exactly 'relu', 'leakyrelu' and 'prelu'; any other act_type raises NotImplementedError. Notably absent: 'gelu', 'silu'/'swish', 'elu' that other BasicSR forks support.

Source

Thrown at ldm_patched/pfn/architecture/block.py:32

####################
# Basic blocks
####################


def act(act_type: str, inplace=True, neg_slope=0.2, n_prelu=1):
    # helper selecting activation
    # neg_slope: for leakyrelu and init of prelu
    # n_prelu: for p_relu num_parameters
    act_type = act_type.lower()
    if act_type == "relu":
        layer = nn.ReLU(inplace)
    elif act_type == "leakyrelu":
        layer = nn.LeakyReLU(neg_slope, inplace)
    elif act_type == "prelu":
        layer = nn.PReLU(num_parameters=n_prelu, init=neg_slope)
    else:
        raise NotImplementedError(
            "activation layer [{:s}] is not found".format(act_type)
        )
    return layer


def norm(norm_type: str, nc: int):
    # helper selecting normalization layer
    norm_type = norm_type.lower()
    if norm_type == "batch":
        layer = nn.BatchNorm2d(nc, affine=True)
    elif norm_type == "instance":
        layer = nn.InstanceNorm2d(nc, affine=False)
    else:
        raise NotImplementedError(
            "normalization layer [{:s}] is not found".format(norm_type)
        )
    return layer

View on GitHub (pinned to ae05379cc9)

Solutions

  1. Use one of: 'relu', 'leakyrelu', 'prelu' (note: 'lrelu' shorthand is not accepted)
  2. If the source config used another activation, map it to the closest supported one (silu->leakyrelu) or extend act() with the missing branch
  3. Validate the act string in your config loader before constructing the network

Example fix

# before
conv = B.conv_block(64, 64, act_type='lrelu')  # -> NotImplementedError

# after
conv = B.conv_block(64, 64, act_type='leakyrelu')
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED_ACTS = {'relu', 'leakyrelu', 'prelu'}

act_type = cfg.get('act', 'leakyrelu').lower()
if act_type == 'lrelu':  # common shorthand
    act_type = 'leakyrelu'
assert act_type in SUPPORTED_ACTS, f'activation must be one of {SUPPORTED_ACTS}, got {act_type!r}'

Type guard

def is_supported_act(act_type: str) -> bool:
    return isinstance(act_type, str) and act_type.lower() in ('relu', 'leakyrelu', 'prelu')

Prevention

When it happens

Trigger: Building a conv_block/RRDBNet with act_type='silu', 'gelu', 'elu', 'true' or any string not in the three supported names; the value comes from the model config dict (act key) of an upscaler definition.

Common situations: Porting a Real-ESRGAN config written for a newer BasicSR that supports more activations; hand-edited YAMLs; typos like 'LeakyRelu' are fine (lowercased) but 'lrelu' is NOT accepted - the full name 'leakyrelu' is required.

Related errors


AI-assisted analysis of lllyasviel/Fooocus@ae05379cc9 (2026-08-15). Data as JSON: /api/errors/43bf617873af0752. Report an issue: GitHub.