lllyasviel/Fooocus · error · NotImplementedError
padding layer [{:s}] is not implemented
Error message
padding layer [{:s}] is not implemented What it means
block.pad() creates the padding layer: 'reflect' -> ReflectionPad2d, 'replicate' -> ReplicationPad2d, and anything else raises NotImplementedError. Zero padding is deliberately not handled here (the comment says 'if padding is zero, do by conv layers') - conv blocks are expected to carry the padding themselves, so pad_type='zero' is also rejected.
Source
Thrown at ldm_patched/pfn/architecture/block.py:63
else:
raise NotImplementedError(
"normalization layer [{:s}] is not found".format(norm_type)
)
return layer
def pad(pad_type: str, padding):
# helper selecting padding layer
# if padding is 'zero', do by conv layers
pad_type = pad_type.lower()
if padding == 0:
return None
if pad_type == "reflect":
layer = nn.ReflectionPad2d(padding)
elif pad_type == "replicate":
layer = nn.ReplicationPad2d(padding)
else:
raise NotImplementedError(
"padding layer [{:s}] is not implemented".format(pad_type)
)
return layer
def get_valid_padding(kernel_size, dilation):
kernel_size = kernel_size + (kernel_size - 1) * (dilation - 1)
padding = (kernel_size - 1) // 2
return padding
class ConcatBlock(nn.Module):
# Concat the output of a submodule to its input
def __init__(self, submodule):
super(ConcatBlock, self).__init__()
self.sub = submodule
def forward(self, x):View on GitHub (pinned to ae05379cc9)
Solutions
- Use 'reflect' or 'replicate', or set padding=0 so the function returns None and lets conv layers handle zero padding
- For 'zero' configs: drop the explicit pad layer and put the padding into the following nn.Conv2d(padding=...)
Example fix
# before
p = B.pad('zero', 1) # -> NotImplementedError
# after: zero pad via the conv itself
conv = nn.Conv2d(64, 64, 3, 1, 1) # padding=1 IS the zero padding
block = nn.Sequential(conv) Defensive patterns
Strategy: validation
Validate before calling
def sanitize_pad(pad_type, padding):
if padding == 0:
return None
p = pad_type.lower()
assert p in ('reflect', 'replicate'), f"pad_type must be reflect/replicate (zero padding belongs in the conv), got {pad_type!r}"
return p
# Real-ESRGAN configs often say 'zero': translate instead of failing
if cfg.get('pad_type') == 'zero':
cfg['pad_type'] = 'reflect'; cfg['padding'] = 0 # conv supplies zero pad Type guard
def is_supported_pad(pad_type: str) -> bool:
return pad_type.lower() in ('reflect', 'replicate') Prevention
- Zero padding is handled by the conv layer, not pad(): use padding=0 for the pad helper
- Translate Real-ESRGAN 'pad_type: zero' configs before passing them to this code
When it happens
Trigger: Calling pad('zero', 1), pad('symmetric', 2), or pad('', 3) - any pad_type outside {'reflect','replicate'} with a non-zero padding amount. Note: if padding == 0 the function returns None before the check, so the error only fires when actual padding is requested with an unsupported type.
Common situations: Real-ESRGAN configs commonly specify pad_type: zero - porting them into this vendored code without changing the value; configs requesting 'symmetric' padding available in other forks.
Related errors
- activation layer [{:s}] is not found
- normalization layer [{:s}] is not found
- scale {scale} is not supported. Supported scales: 2^n and 3.
- scale {scale} is not supported. Supported scales: 2^n and 3.
- Upsample mode [{self.upsampler}] is not found
AI-assisted analysis of lllyasviel/Fooocus@ae05379cc9 (2026-08-15).
Data as JSON: /api/errors/bfe49fdcdda249ef.
Report an issue: GitHub.