{"record":{"id":"f9b75a116e052838","repo":"lllyasviel/Fooocus","slug":"normalization-layer-s-is-not-found","errorCode":null,"errorMessage":"normalization layer [{:s}] is not found","messagePattern":"normalization layer \\[(.+?)\\] is not found","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"ldm_patched/pfn/architecture/block.py","lineNumber":46,"sourceCode":"        layer = nn.LeakyReLU(neg_slope, inplace)\n    elif act_type == \"prelu\":\n        layer = nn.PReLU(num_parameters=n_prelu, init=neg_slope)\n    else:\n        raise NotImplementedError(\n            \"activation layer [{:s}] is not found\".format(act_type)\n        )\n    return layer\n\n\ndef norm(norm_type: str, nc: int):\n    # helper selecting normalization layer\n    norm_type = norm_type.lower()\n    if norm_type == \"batch\":\n        layer = nn.BatchNorm2d(nc, affine=True)\n    elif norm_type == \"instance\":\n        layer = nn.InstanceNorm2d(nc, affine=False)\n    else:\n        raise NotImplementedError(\n            \"normalization layer [{:s}] is not found\".format(norm_type)\n        )\n    return layer\n\n\ndef pad(pad_type: str, padding):\n    # helper selecting padding layer\n    # if padding is 'zero', do by conv layers\n    pad_type = pad_type.lower()\n    if padding == 0:\n        return None\n    if pad_type == \"reflect\":\n        layer = nn.ReflectionPad2d(padding)\n    elif pad_type == \"replicate\":\n        layer = nn.ReplicationPad2d(padding)\n    else:\n        raise NotImplementedError(\n            \"padding layer [{:s}] is not implemented\".format(pad_type)","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/lllyasviel/Fooocus/blob/ae05379cc97bc4361ec8b4ec90193dab21be763f/ldm_patched/pfn/architecture/block.py#L28-L64","documentation":"block.norm() is the normalization factory: it builds BatchNorm2d for 'batch' and InstanceNorm2d for 'instance'; every other norm_type raises NotImplementedError. There is no 'none'/null option here - conv_block callers must skip normalization at a higher level rather than pass a string like 'none'.","triggerScenarios":"Calling norm('none', nc), norm('group', nc), or norm('batch0') - i.e. any norm_type besides 'batch'/'instance'. Typically triggered by a conv_block(act, norm_type='none') call pattern copied from code that treats 'none' as a valid sentinel.","commonSituations":"Configs from other BasicSR forks where norm_type: null / 'none' is written out explicitly; generated model params where the norm field is defaulted to a string instead of None; typos ('Batch', 'instanceNorm').","solutions":["Pass norm_type='batch' or 'instance', or None/False at the conv_block level to skip normalization entirely","Sanitize config values: map 'none'/''/null to None before they reach norm()"],"exampleFix":"# before\nlayer = B.norm('none', 64)  # -> NotImplementedError\n\n# after: skip normalization at the caller level\nconv = B.conv_block(64, 64, norm_type=None)  # norm() never called","handlingStrategy":"validation","validationCode":"def sanitize_norm(norm_type):\n    if norm_type is None:\n        return None\n    n = norm_type.lower()\n    if n in ('', 'none', 'null', 'false'):\n        return None  # caller must then SKIP the norm layer\n    assert n in ('batch', 'instance'), f'norm must be batch/instance/None, got {norm_type!r}'\n    return n\n\nconv = B.conv_block(64, 64, norm_type=sanitize_norm(cfg.get('norm')))","typeGuard":"def is_supported_norm(norm_type) -> bool:\n    return norm_type is None or (isinstance(norm_type, str) and norm_type.lower() in ('batch', 'instance'))","tryCatchPattern":null,"preventionTips":["Use None/False to skip normalization; 'none' as a string is NOT accepted by norm()","Normalize config values: map 'none'/''/null to None before model construction"],"tags":["super-resolution","normalization","block","config","notimplementederror"],"backgroundTag":null,"analyzedSha":"ae05379cc97bc4361ec8b4ec90193dab21be763f","analyzedAt":"2026-08-15T04:23:59.533Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}