Skip to content

armgit / facex

Public Imported from GitHub
0

Full face stack that runs entirely in the browser. Detection, 576-point 3D mesh, recognition, anti-spoof, smile — all WebAssembly, zero server. Apache 2.0.

2.7 KB
Raw Blame

Group bounds and mapped row lifetime

For a unit query q and a group enclosed in a ball of radius R about c, the triangle inequality gives an upper cosine bound of 1 - max(0, ||q-c|| - R)^2 / 2. Visit groups by decreasing bound and stop below the fifth exact score (with 1e-12 numerical slack). Within each visited group use centered integer screening. Global ties prefer the earlier enrollment row.

The fixture uses eight shifted crops of each of 15 repository photos with one held out crop per photo. EdgeFace XS produces all 135 embeddings. Each boundary query is the normalized midpoint toward the most similar other held out vector. The scale test uses 4369 rows per group generated by adding Gaussian noise of standard deviation 0.002 to the eight normalized enrollment views. Groups are supplied at enrollment. This workload tests gallery search and omits production clustering and recognition accuracy.

Reproduce on Linux with NumPy, Pillow and GCC. Select an ext4 temporary directory with enough free space. The script checks raw file page residency with mincore after a cache eviction request. The disk controller cache is uncontrolled.

bash download_weights.sh
make cli
mkdir -p /path/on/ext4/tmp
TMPDIR=/path/on/ext4/tmp OPENBLAS_NUM_THREADS=1 PYTHONPATH=python python tests/bench_gallery_groups.py data/edgeface_xs_fp32.bin

One pinned CPU, separate worker processes, 30 distinct queries per gallery repeated three times after one first lookup. All final IDs and float64 scores matched CompactGallery. Timed passes include first access to previously untouched groups. The indexed processes start with zero raw file pages resident, while the baseline reads all originals during initialization. The index itself was generated before these timings.

65535 rows Near p50 / p95 ms Boundary p50 / p95 ms First query ms Load ms End / peak process RSS MiB
CompactGallery 4.14 / 5.68 4.19 / 5.69 4.71 60.46 158.54 / 283.23
Group search 1.51 / 11.30 2.70 / 14.37 28.62 85.77 191.49 / 192.15
Drop raw mappings after each visited group 1.82 / 9.61 4.47 / 13.08 12.15 35.37 64.54 / 72.96

Median group visits were 2 of 15 near an enrollment view and 8 of 15 at a boundary. On the 120 real fixture rows, CompactGallery took 0.027 / 0.026 ms median near / boundary, compared with 0.441 / 0.550 ms with group-level mapping release. Peak RSS includes loading and Python runtime. Linux can retain file pages in the system page cache after mapping release. Worker memory excludes offline index construction, model inference and the host-wide page cache. Timings, especially one-shot disk timings, vary by machine and cache state.