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.
54 mathematical and engineering tasks for FaceX
Baseline a8d0332. These are engineering tasks with shared implementations. Timings below measure specific operations. The release does not establish a new biometric accuracy or an end-to-end throughput improvement.
| ID | Problem | Implemented solution and verification |
|---|---|---|
| 1 | Cosine overflows for large finite float32 templates | Promote products and reductions to float64. Maximum finite parallel and antiparallel vectors score +1 and -1. |
| 2 | Tiny nonzero vectors lose their direction | Remove the absolute norm cutoff. The smallest positive float32 survives the cosine calculation. |
| 3 | Define the score for an absent direction | Handle zero norm explicitly as zero; identification abstains for a zero query. |
| 4 | Keep cosine in its mathematical domain | Clamp the final result to [-1,1] after accumulation. |
| 5 | Prevent undefined scores entering decisions | Reject nonfinite or incompatible inputs. REST returns 400; the SDK raises ValueError. |
| 6 | Keep SDK and REST decisions numerically consistent | Use the same cosine routine. REST applies its existing strict 0.3 decision rule before rounding the displayed score. |
| 7 | Compare compact output directly | Decode each operand independently as little-endian float32. Array, compact and mixed pairs agree. |
| 8 | Avoid accepting truncated or ambiguous vector representations | Check encoded length, Base64 alphabet, decoded byte count, flat array arity and numeric types. Tested malformed payloads. |
| 9 | Eliminate repeated enrollment normalization | Normalize enrollment rows once, retain an owned matrix and reuse it for subsequent queries. |
| 10 | Search multiple queries together | Score query blocks by matrix multiplication. Tested against a normalized exhaustive reference. |
| 11 | Bound a batch's temporary score matrix | Choose the query block size from a 1 MiB target, with a minimum of one gallery row of scores. Tested across the block boundary. |
| 12 | Find one nearest neighbor without sorting | Use argmax directly for k=1. Tested self matches and duplicate rows. |
| 13 | Find exact top k without sorting the whole gallery | Partition at the kth score and sort only selected candidates. Verified k=4 and k equal to gallery size. |
| 14 | Resolve ties at the kth boundary deterministically | Fill cutoff ties by enrollment order, then rank by score and row ID. Tested duplicate and all-zero scores. |
| 15 | Reject an insufficient best match | Identify applies a user-supplied minimum cosine and returns -1 when insufficient. |
| 16 | Abstain on ambiguous nearest identities | Require separation from the runner-up and reject exact ties. Tested equidistant and duplicate templates. |
| 17 | Avoid inventing a margin for a singleton gallery | A positive required margin yields abstention when no runner-up exists. |
| 18 | Build one enrollment template from several views | Compute a spherical mean over normalized embedding directions. The resulting template has unit length. |
| 19 | Include quality without numerical dependence on weight units | Rescale nonnegative quality weights before accumulation; tested scaling by 1e200 and 1e-200. |
| 20 | Exclude missing or explicitly ignored views | Omit zero vectors and zero-weight views; reject a group with no usable direction. |
| 21 | Select a representative observed view efficiently | The weighted cosine medoid maximizes the dot product with the resultant; O(nD) instead of materializing n squared similarities. Compared to exhaustive pairwise scoring. |
| 22 | Detect contradictory enrollment directions | Reject a numerically vanishing resultant. Antipodal enrollment is a regression fixture. |
| 23 | Quantify within-enrollment consistency | Return normalized resultant length along with the template. Checked against a direct weighted average. |
| 24 | Evaluate all empirical thresholds without a pair-by-threshold matrix | Sort scores once and accumulate true and false accepts. |
| 25 | Treat tied scores as indivisible ROC steps | Evaluate only ends of equal-score runs, including reject-all. Tested discrete tied inputs. |
| 26 | Compute tie-aware AUC | Integrate the empirical ROC and compare to independent positive-negative pair counting with half credit for ties. |
| 27 | Estimate the equal-error crossing | Interpolate between neighboring ROC points. Perfect, reversed and fully tied fixtures give 0, 1 and 0.5. |
| 28 | Select an operating point at a maximum empirical FAR | Maximize true accepts under the budget, minimizing false accepts on a tie. Checked by exhaustive enumeration. |
| 29 | Represent an unattainable nontrivial operating point | Use an explicit reject-all threshold (JSON null) instead of a fabricated numeric cutoff. |
| 30 | Show when the sample cannot resolve a small FAR | Report impostor denominator and its one-count resolution alongside the measured FAR. |
| 31 | Separate threshold selection and evaluation | Accept a separate holdout NPZ and apply the frozen rule; report false accepts and false rejects independently. Caller supplies the independent split. |
| 32 | Quantify uncertainty after zero false accepts | On a frozen independent holdout, report the one-sided exact 95% binomial upper bound via expm1. Tested by inverting the zero-event probability. |
| 33 | Avoid dominance by the majority verification class | Report balanced accuracy on the holdout. Missing classes produce an explicit error. |
| 34 | Eliminate per-record binary parsing overhead | Read the training image index through a structured little-endian memory map. Reject partial records. |
| 35 | Replace Python lists of image indices per identity | Stable-sort the label column and represent each class by its offsets into one order array. |
| 36 | Avoid repeated conversion of the entire class list for impostor sampling | Sample eligible group IDs directly from a NumPy array. The original eligible population is preserved. |
| 37 | Preserve the historical training comparison when changing sampling | Restore first-seen class order and within-class source order. Seeded ordered pairs, including their final shuffle, match the old sampler. |
| 38 | Avoid materializing all cross-validation fold indices | Use contiguous slice boundaries with divmod, preserving remainder distribution, threshold tie handling and held-out results. |
| 39 | Detect undefined cross-validation setups | Validate fold count, vector shapes and finite nondecreasing threshold grids before counting. |
| 40 | Optimize detector aspect-ratio budget exactly | Binary-search the crossing between increasing width and decreasing height capacity and evaluate the boundary neighbors. Compared to the original exhaustive optimizer. |
| 41 | Reuse the geometry of a fixed camera feed | Bound the size/shape result cache to 256 entries; repeated dimensions and pixel budgets avoid the search. |
| 42 | Preserve extreme aspect and padding constraints | Keep the original long-side cap, rounding and 32-pixel padding. Verified 9,012 shape/budget combinations against exhaustive search. |
| 43 | Avoid an allocation-heavy vote for one crop center | Use the sole eligible center directly and scalar clipping for the output coordinates. |
| 44 | Bound the memory of center-density estimation | Vote in blocks of 64 candidate centers using separate x and y comparisons instead of a full n by n by 2 displacement tensor. |
| 45 | Resolve tied crop centers across blocks consistently | Retain the first maximum and reject degenerate boxes. Compared to exhaustive voting including a 513-point case. |
| 46 | Speed up exact overlap suppression | Reject disjoint boxes before arithmetic and cache accepted box areas. Greedy score order, strict IoU threshold and output cap are preserved. |
| 47 | Make repeated guided merges geometrically idempotent | Translate extra boxes and landmarks into fresh records. Repeated merges leave inputs untouched and reproduce the same detections. |
| 48 | Prevent checkpoint A from supplying checkpoint B's first convolution | Store the packed stem inside each checkpoint's own tensor storage. Alternating two distinct stems matches isolated CLI processes bitwise. |
| 49 | Move first-frame weight permutation off the inference path | Transpose the stem at initialization using the existing checked packer. Single-model output matches the baseline on 15 fixture inputs. |
| 50 | Isolate decryption state between native handles | Pass the license key down the initialization call chain; opening with a key no longer authorizes a subsequent keyless open. Checked valid, wrong and absent keys. |
| 51 | Keep model initialization transactional after stem packing | A failed stem allocation follows existing rollback; the allocation harness covers 453 injected failure points and 100 successful cycles. |
| 52 | Eliminate the ConvNeXt skip-connection copy | Read each original activation until its final output element is written. Verified native embedding bytes. |
| 53 | Bound shared forward scratch from tensor lifetimes | Size for the maximum of the ConvNeXt and XCA layouts instead of reserving 2,097,152 floats. Largest ConvNeXt block needs 140,336 floats. |
| 54 | Bound the main activation buffer by actual stage products | The largest HW times C is 784 times 32 rather than 784 times 192. Both static arrays together fall from 8,990,720 to 661,696 bytes; these are reserved bytes, not measured RSS. |
Local paired timings
One pinned x86 Linux CPU, one BLAS thread, seven alternating pairs, median CPU time in ms. Gallery input is synthetic and repeated enrollment is fixed. The vectorized reference performs fresh normalization and stable full sorting for each batch. Enrollment setup is excluded from the reusable gallery measurement. The sampler comparison includes reading the same generated index and checking identical ordered output.
| Operation | Reference | New |
|---|---|---|
| Top 5 for 16 queries against 4,096 rows | 15.513 | 5.019 |
| Sample 2,000 pairs from 60,000 index records | 378.457 | 34.348 |
| Merge 32 sparse scored boxes | 0.477 | 0.029 |
| Guided crop, 32 eligible centers | 0.068 | 0.038 |
| Guided crop, one eligible center | 0.0132 | 0.00151 |
| Repeated rectangle geometry, 1920 by 1080 | 0.00683 | 0.00010 |
Native CLI comparison on 15 repository fixture images resized to 112 by 112 used identical GCC x86-64-v3 flags. Original and updated outputs, including the encrypted-load variant, matched byte for byte. Nine warmed paired runs measured 3.177 and 3.158 ms per embedding including local pipe transfer, too close to claim a meaningful forward-pass speedup. AddressSanitizer and UndefinedBehaviorSanitizer completed the input set. LeakSanitizer cannot enumerate threads under ptrace here; the allocation rollback test was run separately.
An ordinary pair of float32 vectors took 4.57 versus 4.44 microseconds for scalar SDK cosine, seven alternating runs of 5,000 calls. The important change is the wider numerical domain. The normalized gallery costs eight bytes per enrolled component (16 MiB for 4,096 rows of 512) and needs rebuilding after enrollment changes.
Run the checks
Use matching compiler flags for the library and CLI when comparing float bytes.
make check
PYTHONPATH=python OPENBLAS_NUM_THREADS=1 python tests/test_math_pipeline.py
PYTHONPATH=python:docker python tests/test_compare_formats.py
python tests/test_verification_thresholds.py
python tests/verify_checkpoint_isolation.py /path/to/libfacex.so /path/to/facex-cli /path/to/edgeface.bin
python training/scripts/verification_curve.py calibration.npz --far 0.001 --holdout evaluation.npz
Both NPZ inputs to the verification tool contain equal-length arrays named scores and same. The independent-pair model is required for the binomial confidence bound. No population FAR, calibrated access threshold or production latency is claimed from the synthetic or fixture tests.