The legacy display remap in FaceAttributeToJsonString rewrote most
emotions to "Attentive", which hid the v1.4 classifier's real classes.
The remap now applies ONLY to the legacy OpenVINO model's lowercase
classes (sad/happy/neutral/anger/surprise - v1.1 output unchanged);
every other name, i.e. the classes read from emotionsrecognition.names
(Angry, Fear, Happy, Neutral, Sad), passes through verbatim. A retrained
classifier with a different .names list needs no code change.
Verified on the classroom video: faces previously labelled "Attentive"
now read "Angry (100%)"; smiling faces read "Happy (100%)". Parity test
updated to check each pack against its own emotion vocabulary.
Note for client code: v1.4 deployments no longer emit "Attentive" -
anything matching that string must handle Angry/Fear/Sad instead.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
With the heavier v1.4 ONNX age-gender model, interval 20 benchmarks at
throughput parity with the v1.1 pack (16.8 ms / 59 fps vs 16.0 ms / 62
fps on RTX 3070, classroom.mp4, ~3.1 faces/frame) versus 19.9 ms / 50
fps at the old default of 5. Attributes refresh every ~0.8 s on a 25 fps
camera (1.6 s on stable scenes, faster when faces appear), which is
ample for age/gender/emotion; head pose and recognition still run every
frame. Deployments wanting fresher attributes can lower it at runtime
via SetANSRFAttributeInterval. Full test suite passes at the new
default; GetANSRFModelInfo reports "attribute_interval":20.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
New API SetANSRFAttributeInterval(Handle, frames) / UpdateAttributeInterval
(1..60, default 5) controls how often the slow attributes (age/gender +
emotions) refresh per camera; head pose and recognition are unaffected.
GetANSRFModelInfo now reports "attribute_interval". The adaptive logic's
stable-scene branch previously capped at a hardcoded 10 - it now doubles
the configured interval instead (default behaviour 10/5/2 unchanged).
Motivation: the v1.4 ViT age-gender model is heavier per attribute frame
than the old OpenVINO IR. Interval sweep on RTX 3070 (classroom.mp4,
~3.1 faces/frame) vs the v1.1 baseline at 16.0 ms / 62 fps:
interval 5 (default): 19.9 ms / 50 fps (+3.9 ms)
interval 10: 17.1 ms / 58 fps (+1.1 ms)
interval 20: 16.5 ms / 61 fps (parity)
Recommendation: default on 8 GB GPUs; interval 10 on small-VRAM machines.
ANSFR-UnitTest: --bench old|new [interval] runs the sweep.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The re-packed ANS_FaceRecognizer_v1.4.zip (ONNX attribute models only, no
OpenVINO agegender/emotion IRs) is now the official pack and lives in the
canonical distribution folder C:\Projects\SharedCore next to v1.1.
Centralize every hardcoded pack path into three file-scope constants
(kFaceRecognizerV14Zip, kFaceRecognizerV11Zip, kFaceDetectorZip) used by
the model-switch test, classroom demo, benchmark, and parity test - a
future pack bump is a one-line edit. Verified against the official path:
adaface + ONNX attribute backends load and bench at 17.9 ms avg. The
slimmer pack was separately validated from a clean extraction (all
TestModelSwitchV14 checks pass without the OpenVINO fallback files).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
SetANSRFRecognizerModel now records the choice in the face database
(SETTINGS key RECOGNIZER_MODEL_PREF), and LoadEngine restores it when no
explicit choice was made in the current session - so a runtime switch to
ArcFace (or AdaFace) survives server restarts without re-calling the API.
Kept separate from EMBEDDING_MODEL on purpose: only an actual API call is
recorded as a preference. An automatic ArcFace fallback (pre-v1.4 zip
without adafacerecognizer.onnx) is not persisted, so upgrading such a
deployment to the v1.4 pack still gets the AdaFace default.
ANSFR-UnitTest: TestModelSwitchV14 (now also runnable via --test) gains a
simulated restart - release handle, recreate on the same database, and
assert the persisted ArcFace choice is restored and still recognizes the
enrolled user. Verified ALL PASSED.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
TestOutputFormatParity (--parity) runs the identical enroll + inference
flow through the v1.1 pack (arcface + OpenVINO attributes) and the v1.4
pack (adaface + ONNX attributes) and asserts the emitted JSON is
format-identical: same result-object fields, same attribute keys
(Gender/Age/AgeYears/Emotion/Pose), same value vocabularies (Male/Female,
the four Age buckets, Happy/Neutral/Attentive emotion labels with (NN%)),
and that both packs recognize the enrolled user. Verified ALL PASSED on
the RTX 3070 test machine.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- ClassroomAttributesVideoTest (default main): plays classroom.mp4 through
the v1.4 pipeline and overlays user name, Gender/Age, and Emotion parsed
from each result's extra_info JSON; saves an annotated frame every 30
frames to C:\Programs\DemoAssets for headless review.
- --bench old|new|both: per-pack speed benchmark (100 measured frames after
10 warmup, full pipeline with attributes on) run one pack per process.
RTX 3070 laptop results: v1.1 arcface+OpenVINO 17.8 ms avg (56.2 fps) vs
v1.4 adaface+ONNX/TRT 18.2 ms avg (55.1 fps) at 3.1 faces/frame — the
new models carry no throughput cost.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Recognizer: adafacerecognizer.onnx (AdaFace, new default) with automatic
fallback to ansfacerecognizer.onnx (ArcFace) for pre-v1.4 zips. AdaFace
consumes BGR: new AdaFace handler in ONNXEngine skips the BGR2RGB swap,
and the TensorRT paths gate their cvtColor on m_swapRB.
- New C API: SetANSRFRecognizerModel (0=AdaFace, 1=ArcFace),
GetANSRFRecognizerModel, GetANSRFModelInfo. A live switch reloads the
recognizer and regenerates all stored embeddings from the enrolled face
crops; the generating model is persisted in a new SETTINGS table
(EMBEDDING_MODEL) so upgrading an ArcFace database to the AdaFace
default migrates automatically on LoadEngine.
- Attributes: prefer agegender.onnx (ViT: gender_logits [male,female] +
age_pred in years; also handles the single-tensor research export) and
emotionsrecognition.onnx (YOLOv11-cls, classes from .names) behind new
IAgeGenderEstimator/IEmotionsClassifier interfaces, falling back to the
legacy OpenVINO IRs. EP follows hardware: NVIDIA uses TensorRT EP with
disk-cached engines, AMD DirectML, Intel OpenVINO.
- Emotion JSON mapping: handle the new Fear class and the never-matched
surprise label (both map to Attentive).
- ANSFR-UnitTest: TestModelSwitchV14 covers default model selection, ONNX
attribute backends, enrollment, and adaface<->arcface switching.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Repoints the hardcoded fixtures at the installed ANSVIS Server layout rather
than the old E:/C: DemoAssets trees:
- classroom.mp4 now read from C:\ProgramData\ANSCENTER\Shared
- TestCompleteFR1 loads the GPU-specific ServerOptimised zips
(ANS_FaceRecognizer_v1.1_NVIDIAGeForceRTX4070LaptopGPU.zip) and re-enables
the InsertUser call ahead of InsertFace
- main() runs ANSVISTest()
Also comments out the --gpu argument handling in main(), so the harness no
longer sets CUDA_VISIBLE_DEVICES and the single-GPU bisect flag is inert until
that block is restored.
Paths remain machine-specific; this is a developer harness, not a test suite.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Verified on dual RTX 5080: 355/355 detections, both GPUs in round-robin,
zero CUDA errors. Requires TensorRT >= 10.16.1 in SharedCore (10.15.1 has
a Myelin l2cm crash when creating a context on a second Blackwell device).
1. blobFromGpuMats: thread_local GpuMat caches (tl_blob/tl_floatImg) were
device-blind — a pool thread warming GPU[1] then GPU[0] reused device-1
memory with a device-0 stream, causing an async illegal memory access
that poisoned every CUDA context (sticky 700). Track owning device and
rebuild the cache on device switch.
2. runInference: pool round-robin can dispatch to a slot on a different
GPU than the one the caller prepared inputs on. Detect foreign input
GpuMats via cudaPointerGetAttributes and migrate them through a pinned
host staging buffer (two-hop D2H+H2D; direct cross-device cudaMemcpy2D
is unsupported and GeForce has no P2P).
3. warmUp: now pins its own CUDA device before uploading dummy inputs and
returns success/failure; loadNetwork rejects engines whose warmup fails
so broken slots can never join the pool silently.
4. Blackwell builder workaround: setMaxAuxStreams(0) on SM 12.x plus an
.aux0 engine-cache suffix so pre-workaround caches rebuild.
Also: ANSFR-UnitTest gains --gpu N flag (sets CUDA_VISIBLE_DEVICES) for
single-GPU bisection, and rich diagnostics on input-copy failures.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>