From 024d55197b1dcd69e8593e46ceb3e0b5192fece2 Mon Sep 17 00:00:00 2001 From: Tuan Nghia Nguyen Date: Thu, 27 Aug 2026 02:09:29 +1000 Subject: [PATCH] ANSFR: raise default slow-attribute refresh interval to 20 frames 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 --- modules/ANSFR/ANSFR.h | 16 +++++++++------- tests/ANSFR-UnitTest/ANSFR-UnitTest.cpp | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/ANSFR/ANSFR.h b/modules/ANSFR/ANSFR.h index c94522e..bd0fbdc 100644 --- a/modules/ANSFR/ANSFR.h +++ b/modules/ANSFR/ANSFR.h @@ -101,7 +101,9 @@ namespace ANSCENTER // How often the slow attributes (age/gender + emotions) refresh: // every N frames per camera (1 = every frame). Head pose still runs // every frame. The adaptive logic doubles N on stable scenes and - // halves it (min 2) when faces appear/disappear. Default 5. + // halves it (min 2) when faces appear/disappear. Default 20 — + // benchmarked at throughput parity with the v1.1 pack while the + // heavier v1.4 ONNX age-gender model is loaded. bool UpdateAttributeInterval(int frames); int GetAttributeInterval() const { return _attributeInterval; } @@ -195,7 +197,7 @@ namespace ANSCENTER int _faceThresholdSize; // number of frames to consider for face recognition bool _enableFaceQueue; double _faceDetectorScoreThreshold; // Face threshold score for face checker - int _attributeInterval{ 5 }; // Run slow attributes every N frames (1=every frame) + int _attributeInterval{ 20 }; // Run slow attributes every N frames (1=every frame) FaceChecker faceChecker; @@ -276,7 +278,7 @@ namespace ANSCENTER std::unordered_map trackIdentities; // trackId → accumulated identity // Adaptive interval state - int currentAttributeInterval = 5; // current adaptive interval + int currentAttributeInterval = 20; // current adaptive interval int stableFrameCount = 0; // frames with no new/lost trackIds int previousTrackIdCount = 0; // trackId count from last frame @@ -290,7 +292,7 @@ namespace ANSCENTER attributeFrameCounter = 0; cachedAttributes.clear(); trackIdentities.clear(); - currentAttributeInterval = 5; + currentAttributeInterval = 20; stableFrameCount = 0; previousTrackIdCount = 0; } @@ -399,10 +401,10 @@ extern "C" ANSFR_API int GetANSRFRecognizerModel(ANSCENTER::ANSFacialRe // {"recognizer_model":"adaface","agegender_backend":"onnx","emotion_backend":"onnx",...} extern "C" ANSFR_API int GetANSRFModelInfo(ANSCENTER::ANSFacialRecognition** Handle, LStrHandle modelInfo); // Slow-attribute (age/gender + emotions) refresh interval in frames per -// camera (1 = every frame, default 5; clamped to [1, 60]). Larger values +// camera (1 = every frame, default 20; clamped to [1, 60]). Larger values // cut the attribute-model GPU cost proportionally at the price of slower -// attribute updates — useful on smaller GPUs with the heavier v1.4 ONNX -// age-gender model. Returns 1 on success, -1 on invalid arguments. +// attribute updates; lower it for the freshest attributes on GPUs with +// headroom. Returns 1 on success, -1 on invalid arguments. extern "C" ANSFR_API int SetANSRFAttributeInterval(ANSCENTER::ANSFacialRecognition** Handle, int frames); diff --git a/tests/ANSFR-UnitTest/ANSFR-UnitTest.cpp b/tests/ANSFR-UnitTest/ANSFR-UnitTest.cpp index 044faa7..d95e72c 100644 --- a/tests/ANSFR-UnitTest/ANSFR-UnitTest.cpp +++ b/tests/ANSFR-UnitTest/ANSFR-UnitTest.cpp @@ -1991,7 +1991,7 @@ int ClassroomAttributesVideoTest() static void RunSinglePackBenchmark(const std::string& label, const std::string& modelZip, const std::string& dbFolder, int warmupFrames = 10, int measuredFrames = 100, - int attributeInterval = 0) // 0 = keep the DLL default (5) + int attributeInterval = 0) // 0 = keep the DLL default (20) { const std::string videoPath = "C:\\Programs\\DemoAssets\\Videos\\classroom.mp4"; const std::string detectorZip = kFaceDetectorZip;