{"record":{"id":"d2af322650b1848d","repo":"deepfakes/faceswap","slug":"too-many-identities-num-identities-max-len-i","errorCode":null,"errorMessage":"Too many identities: {num_identities}. Max: {len(identities)}","messagePattern":"Too many identities: (.+?)\\. Max: (.+?)","errorType":"exception","errorClass":"FaceswapError","httpStatus":null,"severity":"error","filePath":"lib/training/data/data_set.py","lineNumber":72,"sourceCode":"    ----------\n    index\n        The index of the current label\n    num_identities\n        The number of identities that belong to the label set\n    next_identity\n        ``True`` to return the next identity for the given index. Default: ``False``\n\n    Returns\n    -------\n    The current or next label. Labels go A-Z,0-9,a-z\n    \"\"\"\n    identities = [chr(i) for i in range(65, 65 + 26)]\n    if num_identities > len(identities):\n        identities += [chr(i) for i in range(48, 48 + 10)]\n    if num_identities > len(identities):\n        identities += [chr(i) for i in range(97, 97 + 26)]\n    if num_identities > len(identities):\n        raise FaceswapError(f\"Too many identities: {num_identities}. Max: {len(identities)}\")\n    identities = identities[:num_identities]\n    index = index % num_identities\n    if not next_identity:\n        return identities[index]\n    index += 1 if index + 1 < num_identities else -index\n    return identities[index]\n\n\ndef get_sorted_images(folder: str) -> list[str]:\n    \"\"\"For the given folder return the sorted list of potential training images\n\n    Parameters\n    ----------\n    folder\n        The folder containing faceswap training images\n\n    Returns\n    -------","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/deepfakes/faceswap/blob/f530cb7508ae670f6474f8a7d9c4df94705cf96b/lib/training/data/data_set.py#L54-L90","documentation":"Identity labels are built from single characters: A-Z (26), then 0-9 (10), then a-z (26), capping at 62 concurrent identities. If the number of detected identities in the dataset exceeds 62, this FaceswapError aborts label assignment. It reflects a hard design limit of the labelling scheme, not a resource issue.","triggerScenarios":"Running identity-aware training/sorting on a dataset clustering into more than 62 distinct identities; identity threshold set low enough that noise creates many small clusters.","commonSituations":"Large multi-person datasets (crowd footage, celebrity sets) in identity plugin usage; overly-sensitive clustering producing spurious extra identities.","solutions":["Reduce the number of identities: raise the clustering distance/threshold so nearby faces merge.","Split the dataset into subsets of <=62 identities and process separately.","Filter out low-face-count identity clusters (noise) before labelling."],"exampleFix":"# identity plugin config\n# before\nidentity_threshold = 0.3  # over-splits -> 80 identities -> FaceswapError\n# after\nidentity_threshold = 0.6  # merges clusters under 62 identities","handlingStrategy":"validation","validationCode":"MAX_IDENTITIES = 62\nassert num_identities <= MAX_IDENTITIES, \\\n    f'{num_identities} identities exceeds label limit {MAX_IDENTITIES}; raise threshold or split data'","typeGuard":"def within_identity_limit(n: int) -> bool:\n    return isinstance(n, int) and 0 < n <= 62","tryCatchPattern":"try:\n    label = get_identity_label(num_identities, index)\nexcept FaceswapError as err:\n    if 'Too many identities' in str(err):\n        raise SystemExit('raise identity_threshold or split the dataset')\n    raise","preventionTips":["Tune the identity clustering threshold so clusters stay under 62.","Prune single-face noise clusters before labelling.","Split very large multi-person datasets into per-group runs."],"tags":["identity","clustering","dataset-size","config"],"backgroundTag":null,"analyzedSha":"f530cb7508ae670f6474f8a7d9c4df94705cf96b","analyzedAt":"2026-08-15T02:59:26.626Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}