lllyasviel/Fooocus · error · NotImplementedError
network_name={network_name}
Error message
network_name={network_name} What it means
Raised by facexlib's generate_config() when building a RetinaFace detection model with a network_name that is neither 'mobile0.25' nor 'resnet50'. The factory only ships two backbone configs, so any other string falls through to NotImplementedError. It fires inside RetinaFace.__init__ (and init_detection_model), i.e. at model construction time before any inference.
Source
Thrown at extras/facexlib/detection/retinaface.py:68
'epoch': 100,
'decay1': 70,
'decay2': 90,
'image_size': 840,
'return_layers': {
'layer2': 1,
'layer3': 2,
'layer4': 3
},
'in_channel': 256,
'out_channel': 256
}
if network_name == 'mobile0.25':
return cfg_mnet
elif network_name == 'resnet50':
return cfg_re50
else:
raise NotImplementedError(f'network_name={network_name}')
class RetinaFace(nn.Module):
def __init__(self, network_name='resnet50', half=False, phase='test', device=None):
self.device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') if device is None else device
super(RetinaFace, self).__init__()
self.half_inference = half
cfg = generate_config(network_name)
self.backbone = cfg['name']
self.model_name = f'retinaface_{network_name}'
self.cfg = cfg
self.phase = phase
self.target_size, self.max_size = 1600, 2150
self.resize, self.scale, self.scale1 = 1., None, None
self.mean_tensor = torch.tensor([[[[104.]], [[117.]], [[123.]]]], device=self.device)View on GitHub (pinned to ae05379cc9)
Solutions
- Use exactly 'mobile0.25' (lightweight) or 'resnet50' (accurate) as network_name.
- Check for typos/case differences in the config value passed to init_detection_model or RetinaFace.
- If you truly need another backbone, add a cfg dict for it in extras/facexlib/detection/retinaface.py and return it from generate_config(), plus a matching pretrained URL.
- Downstream (e.g. GFPGAN/CodeFormer restore) usually requires 'retinaface_resnet50'; pass that name.
Example fix
// before
model = init_detection_model('resnet18', device=device)
// after
model = init_detection_model('resnet50', device=device) # or 'mobile0.25' Defensive patterns
Strategy: validation
Validate before calling
VALID_NETWORKS = {'mobile0.25', 'resnet50'}
if network_name not in VALID_NETWORKS:
raise ValueError(f'network_name must be one of {sorted(VALID_NETWORKS)}, got {network_name!r}') Type guard
def is_valid_retinaface_network(name: str) -> bool:
return name in {'mobile0.25', 'resnet50'} Try / catch
try:
model = init_detection_model(network_name, device=device)
except NotImplementedError as e:
logger.error('Unsupported RetinaFace backbone: %s (use mobile0.25 or resnet50)', network_name)
raise Prevention
- Whitelist the two valid names at the config/UI boundary before constructing the model.
- Add unit tests asserting exact accepted strings so renames surface early.
- Keep model-name constants in one place instead of scattering string literals.
When it happens
Trigger: Calling RetinaFace(network_name='resnet18') / init_detection_model(det_model='resnet18', ...) or any typo like 'MobileNet0.25', 'mobile0_25', 'resnet101'. Only exact strings 'mobile0.25' and 'resnet50' are accepted.
Common situations: Copying a model name from another repo (e.g. insightface's det names or IR-SE variants), typo in YAML/CLI config, or trying to plug a custom backbone into facexlib without extending generate_config.
Related errors
- {model_name} is not implemented.
- {model_name} is not implemented.
- Max depth of recursive function `tie_encoder_to_decoder` rea
- No paddings to do, output_size must be None or {}
- Not (0 <= inner_padding_factor <= 1.0)
AI-assisted analysis of lllyasviel/Fooocus@ae05379cc9 (2026-08-15).
Data as JSON: /api/errors/c22d78e3d5c1249d.
Report an issue: GitHub.