--- library_name: "fastforks" pipeline_tag: "image-feature-extraction" license: "other" license_name: "noncommercial" license_link: "https://huggingface.co/bytedance-research/LVFace/blob/b12702ab1f5c721748e054a66dc90e1edd1f0724/README.md" tags: - "retrieval" - "image-retrieval" - "visual-place-recognition" - "global-descriptor" - "cuda" - "pytorch" - "fastforks" - "fastforks-card" --- # LVFace (fastforks) LVFace (You et al., ICCV 2025 Highlight, ByteDance): face recognition with a plain vision transformer trained on Glint360K with progressive cluster optimisation. It turns an aligned face crop into a 512-d unit descriptor; the dot product of two descriptors is the cosine similarity used for face verification (same person or not) and face search. Sizes T / S / B / L (76 MB to 1 GB). The input is a face crop already aligned to the standard five-point template at 112 x 112 (the face detector and aligner are not part of the model; see the retinaface / yunet pose models for detection). This repo is the model card only: it holds no weights. fastforks downloads the authors' weights from the links below and checks them against the SHA-256 in the model card. Code: . Kernels for the `kernels` backend: . Original code: at `80bd20c8bb78`. Author weight repos: . Task: retrieval. Tier: experimental. Outputs: `descriptor`. Backends: `portable`, `kernels`. Input: one RGB image. Output: a global descriptor `[D]` (unit L2 norm) for image retrieval / visual place recognition; `fastforks.retrieval.top_k` and `pairs` find the nearest images (cosine similarity) on the GPU. ## Variants Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in [`card.toml`](https://github.com/kleinicke/fastforks/blob/main/src/fastforks/retrieval/models/lvface/card.toml). | variant | weights (author link) | SHA-256 | weights licence | commercial use | |---|---|---|---|---| | `lvface-b@1` | [LVFace-B_Glint360K.pt](https://huggingface.co/bytedance-research/LVFace/resolve/b12702ab1f5c721748e054a66dc90e1edd1f0724/LVFace-B_Glint360K/LVFace-B_Glint360K.pt) | `143ded01bf57` | LicenseRef-noncommercial | **no** | | `lvface-l@1` | [LVFace-L_Glint360K.pt](https://huggingface.co/bytedance-research/LVFace/resolve/b12702ab1f5c721748e054a66dc90e1edd1f0724/LVFace-L_Glint360K/LVFace-L_Glint360K.pt) | `00bb4e6a5314` | LicenseRef-noncommercial | **no** | | `lvface-s@1` | [LVFace-S_Glint360K.pt](https://huggingface.co/bytedance-research/LVFace/resolve/b12702ab1f5c721748e054a66dc90e1edd1f0724/LVFace-S_Glint360K/LVFace-S_Glint360K.pt) | `6c62c43bde1a` | LicenseRef-noncommercial | **no** | | `lvface-t@1` | [LVFace-T_Glint360K.pt](https://huggingface.co/bytedance-research/LVFace/resolve/b12702ab1f5c721748e054a66dc90e1edd1f0724/LVFace-T_Glint360K/LVFace-T_Glint360K.pt) | `1f5b73d6f7a1` | LicenseRef-noncommercial | **no** | ## Licence Original-code strings, recorded as they are (research-use package; check them before any other use). Code: MIT. Licence files: `LICENSE`. Training data: Glint360K (InsightFace: 17.1 M face images of 360k identities) (Trained on Glint360K (model table of the HF README); the dataset and the models trained on it are non-commercial research only (InsightFace).). Licence evidence: https://huggingface.co/bytedance-research/LVFace/blob/b12702ab1f5c721748e054a66dc90e1edd1f0724/README.md (metadata: license mit; License section: 'the models downloaded from our repo follow the above license policy (which is for non-commercial research purposes only)') ; https://github.com/deepinsight/insightface/blob/master/recognition/partial_fc/README.md (Glint360K licence) ## Input size any H x W >= 32, padded to a multiple of 32 Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `lvface-b` 3000x4000 (0.6 GiB peak allocated, 0.7 reserved); `lvface-l` 3000x4000 (0.9 GiB peak allocated, 0.9 reserved); `lvface-s` 3000x4000 (0.6 GiB peak allocated, 0.6 reserved); `lvface-t` 3000x4000 (0.5 GiB peak allocated, 0.5 reserved) ## Speed and memory ### Retrieval, synthetic, 480x640 | model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `lvface-b` | 17.1 | 17.4 | 6.47 | 5.93 | 2.9x | 1.1x | 688 / 704 | 254 / 276 | 255 / 278 | | `lvface-l` | 17.4 | 18.2 | 6.89 | 6.52 | 2.7x | 1.1x | 1500 / 1510 | 526 / 546 | 527 / 546 | | `lvface-s` | 8.76 | 9.18 | 4.05 | 3.39 | 2.6x | 1.2x | 472 / 486 | 182 / 210 | 183 / 232 | | `lvface-t` | 8.64 | 8.65 | 3.93 | 3.38 | 2.6x | 1.2x | 146 / 160 | 73 / 100 | 73 / 102 | ### Startup and first call | model | load (s): original | portable | kernels | first call (s): original | portable | kernels | | --- | --- | --- | --- | --- | --- | --- | | `lvface-b` | 1.52 | 0.20 | 0.70 | 0.02 | 0.01 | 0.13 | | `lvface-l` | 3.17 | 0.45 | 0.95 | 0.02 | 0.01 | 0.13 | | `lvface-s` | 0.96 | 0.15 | 0.54 | 0.01 | 0.01 | 0.13 | | `lvface-t` | 0.26 | 0.16 | 0.33 | 0.02 | 0.24 | 0.15 | ### torch.compile and TensorRT | model | input | time: portable | compile | TensorRT (fp16 unless shown) | kernels | preparation: compile (cold first call) | ONNX + engine build | peak MiB (alloc / reserved): portable | compile | kernels | TensorRT (engine + torch) | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `lvface-b` | 480x640 | 6.47 ms | 3.79 ms | 1.24 ms | 5.93 ms | 10.0 s | 20.2 s | 254 / 276 | 286 / 296 | 255 / 278 | 480 / 498 | | `lvface-l` | 480x640 | 6.89 ms | 4.28 ms | 2.00 ms | 6.52 ms | 10.2 s | 23.9 s | 526 / 546 | 558 / 566 | 527 / 546 | 1043 / 1058 | | `lvface-s` | 480x640 | 4.05 ms | 2.22 ms | 0.756 ms | 3.39 ms | 7.17 s | 15.1 s | 182 / 210 | 214 / 230 | 183 / 232 | 344 / 368 | | `lvface-t` | 480x640 | 3.93 ms | 2.05 ms | 0.371 ms | 3.38 ms | 6.99 s | 13.7 s | 73 / 100 | 105 / 120 | 73 / 102 | 140 / 164 | Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB). Hardware, protocol and caveats: [benchmarks](https://github.com/kleinicke/fastforks/blob/main/docs/benchmarks.md) (RTX 5060 Ti 16 GB, sm_120). Original = the original code named above at the precision of portable (fp16, or `(fp32)` where fp16 is unsupported or not finite); original fp32 = its default fp32 run. Peak memory is the torch allocator's. ## Accuracy ### On public datasets Every query's descriptor against every database descriptor (cosine similarity, exact top-k on the GPU); a query counts as found at k when one of its k nearest database images is within 25 m (UTM positions of the file names), the standard visual place recognition protocol. Original = the original code named under Details, same checkpoint and protocol. | variant | dataset | original fp32 | portable | portable fp32 | note | |---|---|---|---|---|---| | `lvface-t` | CALFW (cross-age LFW), 6000 official pairs, 10-fold verification accuracy / AUC % | 64.10 / 69.63 | 64.58 / 69.64 | 64.65 / 69.64 | | | `lvface-s` | CALFW (cross-age LFW), 6000 official pairs, 10-fold verification accuracy / AUC % | 69.47 / 75.78 | 69.28 / 75.78 | 69.45 / 75.78 | | | `lvface-b` | CALFW (cross-age LFW), 6000 official pairs, 10-fold verification accuracy / AUC % | 78.17 / 84.92 | 78.20 / 84.92 | 78.15 / 84.92 | | | `lvface-l` | CALFW (cross-age LFW), 6000 official pairs, 10-fold verification accuracy / AUC % | 78.58 / 84.82 | 78.58 / 84.82 | 78.52 / 84.82 | | Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks d1aa9702d, 2026-11-30. ### Parity with the original code Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.02 and p99 <= 0.25 (absolute error of the output `descriptor`). ## Limitations - Face crops only: the network expects a face aligned to the standard 112 x 112 five-point template (as insightface's `norm_crop`); whole photos or unaligned crops give unreliable descriptors. Detection and alignment are not part of the model. - Weights are for non-commercial research use: the model card says MIT, but its README states the models are for non-commercial research only, and Glint360K itself (and models trained on it) is non-commercial research data per InsightFace. Listed as non-commercial (`LicenseRef-noncommercial`). - The kernels backend (CUDA, fp16) accumulates the token GEMMs in fp16 and replays the network from a CUDA graph per batch size, captured on its second call; the first call of a new batch size runs eagerly. ## Usage ```python from fastforks import retrieval # non-commercial weights: run with FASTFORKS_NONCOMMERCIAL=1 in the environment model = retrieval.load("lvface-b") # mode="auto": the preferred backend from recorded measurements result = model("photo.jpg") result.descriptor # [D] float32, unit norm # fastforks.retrieval.top_k(queries, database, k=5): the nearest database images result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16') ``` Install with `pip install fastforks` (see ). Other variants: `lvface-b`, `lvface-l`, `lvface-s`, `lvface-t`. ## Kernels backend `retrieval.load("lvface-b", mode="kernels")` runs our CUDA kernels (`fvm_conv`). It needs a prebuilt kernel for your GPU architecture (downloaded from on first use) and a recent NVIDIA driver; if there is none it raises `BackendUnavailableError` with the reason and never falls back silently. `mode="auto"` picks `kernels` when it can run and logs the choice.