{"record":{"id":"d7390af05c4d9060","repo":"lllyasviel/Fooocus","slug":"model-name-is-not-implemented","errorCode":null,"errorMessage":"{model_name} is not implemented.","messagePattern":"(.+?) is not implemented\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"extras/facexlib/detection/__init__.py","lineNumber":16,"sourceCode":"import torch\nfrom copy import deepcopy\n\nfrom extras.facexlib.utils import load_file_from_url\nfrom .retinaface import RetinaFace\n\n\ndef init_detection_model(model_name, half=False, device='cuda', model_rootpath=None):\n    if model_name == 'retinaface_resnet50':\n        model = RetinaFace(network_name='resnet50', half=half, device=device)\n        model_url = 'https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_Resnet50_Final.pth'\n    elif model_name == 'retinaface_mobile0.25':\n        model = RetinaFace(network_name='mobile0.25', half=half, device=device)\n        model_url = 'https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_mobilenet0.25_Final.pth'\n    else:\n        raise NotImplementedError(f'{model_name} is not implemented.')\n\n    model_path = load_file_from_url(\n        url=model_url, model_dir='facexlib/weights', progress=True, file_name=None, save_dir=model_rootpath)\n\n    # TODO: clean pretrained model\n    load_net = torch.load(model_path, map_location=lambda storage, loc: storage, weights_only=True)\n    # remove unnecessary 'module.'\n    for k, v in deepcopy(load_net).items():\n        if k.startswith('module.'):\n            load_net[k[7:]] = v\n            load_net.pop(k)\n    model.load_state_dict(load_net, strict=True)\n    model.eval()\n    model = model.to(device)\n    return model\n","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/lllyasviel/Fooocus/blob/ae05379cc97bc4361ec8b4ec90193dab21be763f/extras/facexlib/detection/__init__.py#L1-L32","documentation":"facexlib's init_detection_model only supports two detection model names: 'retinaface_resnet50' and 'retinaface_mobile0.25'. Any other string raises NotImplementedError before any weights are loaded or downloaded.","triggerScenarios":"Calling init_detection_model('retinaface_mobilenet') (wrong name), 'resnet50' (missing prefix), or a new architecture name that this vendored facexlib version never implemented.","commonSituations":"Copy-pasting model names from other facexlib/GFPGAN versions or READMEs; name drift between upstream facexlib releases and the vendored copy in extras/; users assuming any timm backbone name works.","solutions":["Use exactly 'retinaface_resnet50' or 'retinaface_mobile0.25'","Check the literal strings in extras/facexlib/detection/__init__.py if unsure which names this vendored version supports","Upgrade/patch facexlib locally if you genuinely need another detection backbone"],"exampleFix":"// before\ninit_detection_model('resnet50', half=True, device='cuda')\n\n// after\ninit_detection_model('retinaface_resnet50', half=True, device='cuda')","handlingStrategy":"type-guard","validationCode":"SUPPORTED_DETECTION_MODELS = {'retinaface_resnet50', 'retinaface_mobile0.25'}\nassert model_name in SUPPORTED_DETECTION_MODELS, f'use one of {SUPPORTED_DETECTION_MODELS}'","typeGuard":"def is_supported_detection_model(name: str) -> bool:\n    return name in {'retinaface_resnet50', 'retinaface_mobile0.25'}","tryCatchPattern":"try:\n    det = init_detection_model(name)\nexcept NotImplementedError:\n    det = init_detection_model('retinaface_resnet50')  # safe default","preventionTips":["Use a constant/enum for model names instead of free strings","Pin the vendored facexlib version in docs","Fail fast on unknown names with the supported list in the message"],"tags":["facexlib","face-detection","model-name","not-implemented"],"backgroundTag":null,"analyzedSha":"ae05379cc97bc4361ec8b4ec90193dab21be763f","analyzedAt":"2026-08-15T04:23:59.533Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}