LocalAI/docs/content/features
Ettore Di Giacinto f5eb13d3c2
feat(insightface): add antispoofing (liveness) detection (#9515)
* feat(insightface): add antispoofing (liveness) detection

Light up the anti_spoofing flag that was parked during the first pass.
Both FaceVerify and FaceAnalyze now run the Silent-Face MiniFASNetV2 +
MiniFASNetV1SE ensemble (~4 MB, Apache 2.0, CPU <10ms) when the flag is
set. Failed liveness on either image vetoes FaceVerify regardless of
embedding similarity. Every insightface* gallery entry now ships the
MiniFASNet ONNX weights so existing packs light up after reinstall.

Setting the flag against a model without the MiniFASNet files returns
FAILED_PRECONDITION (HTTP 412) with a clear install message — no
silent is_real=false.

FaceVerifyResponse gained per-image img{1,2}_is_real and
img{1,2}_antispoof_score (proto 9-12); FaceAnalysis's existing
is_real/antispoof_score fields are now populated. Schema fields are
pointers so they are fully absent from the JSON response when
anti_spoofing was not requested — avoids collapsing "not checked" with
"checked and fake" under Go's omitempty on bool.

Validated end-to-end over HTTP against a local install:
- verify + anti_spoofing, both real -> verified=true, score ~0.76
- verify + anti_spoofing, img2 spoof -> verified=false, img2_is_real=false
- analyze + anti_spoofing -> is_real and score per face
- flag against model without MiniFASNet -> HTTP 412 fail-loud

Assisted-by: Claude:claude-opus-4-7 go vet

* test(insightface): wire test target into test-extra

The root Makefile's `test-extra` already runs
`$(MAKE) -C backend/python/insightface test`, but the backend's
Makefile never defined the target — so the command silently errored
and the suite was never executed in CI. Adding the two-line target
(matching ace-step/Makefile) hooks `test.sh` → `runUnittests` →
`python -m unittest test.py`, which discovers both the pre-existing
engine classes (InsightFaceEngineTest, OnnxDirectEngineTest) and the
new AntispoofingTest. Each class skips gracefully when its weights
can't be downloaded from a network-restricted runner.

Assisted-by: Claude:claude-opus-4-7

* test(insightface): exercise antispoofing in e2e-backends (both paths)

Add a `face_antispoof` capability to the Ginkgo e2e suite and extend
the existing FaceVerify + FaceAnalyze specs with liveness assertions
covering BOTH paths:

  real fixture -> is_real=true, score>0, verified stays true
  spoof fixture -> is_real=false, verified vetoed to false

The spoof fixture is upstream's own `image_F2.jpg` (via the yakhyo
mirror) — verified locally against the MiniFASNetV2+V1SE ensemble to
classify as is_real=false with score ~0.013. That makes the assertion
deterministic across CI runs; synthetic/derived spoofs fool the model
unpredictably and would be flaky.

Makefile wires it up end-to-end:
- New INSIGHTFACE_ANTISPOOF_* cache dir + two ONNX downloads with
  pinned SHAs, matching the gallery entries.
- insightface-antispoof-models target shared by both backend configs.
- FACE_SPOOF_IMAGE_URL passed via BACKEND_TEST_FACE_SPOOF_IMAGE_URL.
- Both e2e targets (buffalo-sc + opencv) now:
  * depend on insightface-antispoof-models
  * pass antispoof_v2_onnx / antispoof_v1se_onnx in BACKEND_TEST_OPTIONS
  * include face_antispoof in BACKEND_TEST_CAPS

backend_test.go adds the new capability constant and a faceSpoofFile
fixture resolved the same way as faceFile1/2/3. Spoof assertions are
gated on both capFaceAntispoof AND faceSpoofFile being set, so a test
config that omits the spoof fixture degrades gracefully to "real path
only" instead of failing.

Assisted-by: Claude:claude-opus-4-7 go vet
2026-04-23 18:28:15 +02:00
..
_index.en.md fix(docs): fix broken references to distributed mode 2026-04-03 09:46:06 +02:00
agents.md fix(docs): fix broken references to distributed mode 2026-04-03 09:46:06 +02:00
api-discovery.md feat(api): Allow coding agents to interactively discover how to control and configure LocalAI (#9084) 2026-04-04 15:14:35 +02:00
audio-to-text.md chore(docs): update transcription endpoint 2026-04-14 14:14:54 +00:00
authentication.md fix(docs): fix broken references to distributed mode 2026-04-03 09:46:06 +02:00
backend-monitor.md fix(backend-monitor): accept model as a query parameter (#9411) 2026-04-21 22:06:35 +02:00
backends.md fix(docs): fix broken references to distributed mode 2026-04-03 09:46:06 +02:00
constrained_grammars.md fix(docs): fix broken references to distributed mode 2026-04-03 09:46:06 +02:00
distributed-mode.md fix(docs): fix broken references to distributed mode 2026-04-03 09:46:06 +02:00
distributed_inferencing.md fix(docs): fix broken references to distributed mode 2026-04-03 09:46:06 +02:00
distribution.md fix(docs): commit distribution.md 2026-04-03 10:14:13 +02:00
embeddings.md feat(face-recognition): add insightface/onnx backend for 1:1 verify, 1:N identify, embedding, detection, analysis (#9480) 2026-04-22 21:55:41 +02:00
face-recognition.md feat(insightface): add antispoofing (liveness) detection (#9515) 2026-04-23 18:28:15 +02:00
fine-tuning.md fix(docs): Use notice instead of alert (#9134) 2026-03-25 13:55:48 +01:00
gpt-vision.md fix(docs): fix broken references to distributed mode 2026-04-03 09:46:06 +02:00
GPU-acceleration.md feat(rocm): bump to 7.x (#9323) 2026-04-12 08:51:30 +02:00
image-generation.md fix(docs): fix broken references to distributed mode 2026-04-03 09:46:06 +02:00
mcp.md fix(docs): fix broken references to distributed mode 2026-04-03 09:46:06 +02:00
mlx-distributed.md feat(mlx-distributed): add new MLX-distributed backend (#8801) 2026-03-09 17:29:32 +01:00
model-gallery.md fix(docs): fix broken references to distributed mode 2026-04-03 09:46:06 +02:00
object-detection.md feat(face-recognition): add insightface/onnx backend for 1:1 verify, 1:N identify, embedding, detection, analysis (#9480) 2026-04-22 21:55:41 +02:00
openai-functions.md docs: document tool calling on vLLM and MLX backends 2026-04-13 16:58:55 +00:00
openai-realtime.md Remove header from OpenAI Realtime API documentation 2026-04-09 09:00:28 +02:00
p2p.md feat: Add documentation for undocumented API endpoints (#8852) 2026-03-08 17:59:33 +01:00
quantization.md fix(docs): Use notice instead of alert (#9134) 2026-03-25 13:55:48 +01:00
reranker.md fix(docs): fix broken references to distributed mode 2026-04-03 09:46:06 +02:00
runtime-settings.md fix(docs): fix broken references to distributed mode 2026-04-03 09:46:06 +02:00
sound-generation.md feat: Add documentation for undocumented API endpoints (#8852) 2026-03-08 17:59:33 +01:00
stores.md feat(face-recognition): add insightface/onnx backend for 1:1 verify, 1:N identify, embedding, detection, analysis (#9480) 2026-04-22 21:55:41 +02:00
text-generation.md feat(backend): add turboquant llama.cpp-fork backend (#9355) 2026-04-15 01:25:04 +02:00
text-to-audio.md fix(docs): fix broken references to distributed mode 2026-04-03 09:46:06 +02:00
video-generation.md feat: Add documentation for undocumented API endpoints (#8852) 2026-03-08 17:59:33 +01:00
voice-activity-detection.md feat: Add documentation for undocumented API endpoints (#8852) 2026-03-08 17:59:33 +01:00
voice-recognition.md feat: voice recognition (#9500) 2026-04-23 12:07:14 +02:00