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 <noreply@anthropic.com>
This commit is contained in:
2026-08-27 02:09:29 +10:00
co-authored by Claude Fable 5
parent f34817c620
commit 024d55197b
2 changed files with 10 additions and 8 deletions
+9 -7
View File
@@ -101,7 +101,9 @@ namespace ANSCENTER
// How often the slow attributes (age/gender + emotions) refresh: // How often the slow attributes (age/gender + emotions) refresh:
// every N frames per camera (1 = every frame). Head pose still runs // every N frames per camera (1 = every frame). Head pose still runs
// every frame. The adaptive logic doubles N on stable scenes and // 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); bool UpdateAttributeInterval(int frames);
int GetAttributeInterval() const { return _attributeInterval; } int GetAttributeInterval() const { return _attributeInterval; }
@@ -195,7 +197,7 @@ namespace ANSCENTER
int _faceThresholdSize; // number of frames to consider for face recognition int _faceThresholdSize; // number of frames to consider for face recognition
bool _enableFaceQueue; bool _enableFaceQueue;
double _faceDetectorScoreThreshold; // Face threshold score for face checker 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; FaceChecker faceChecker;
@@ -276,7 +278,7 @@ namespace ANSCENTER
std::unordered_map<int, TrackIdentity> trackIdentities; // trackId → accumulated identity std::unordered_map<int, TrackIdentity> trackIdentities; // trackId → accumulated identity
// Adaptive interval state // 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 stableFrameCount = 0; // frames with no new/lost trackIds
int previousTrackIdCount = 0; // trackId count from last frame int previousTrackIdCount = 0; // trackId count from last frame
@@ -290,7 +292,7 @@ namespace ANSCENTER
attributeFrameCounter = 0; attributeFrameCounter = 0;
cachedAttributes.clear(); cachedAttributes.clear();
trackIdentities.clear(); trackIdentities.clear();
currentAttributeInterval = 5; currentAttributeInterval = 20;
stableFrameCount = 0; stableFrameCount = 0;
previousTrackIdCount = 0; previousTrackIdCount = 0;
} }
@@ -399,10 +401,10 @@ extern "C" ANSFR_API int GetANSRFRecognizerModel(ANSCENTER::ANSFacialRe
// {"recognizer_model":"adaface","agegender_backend":"onnx","emotion_backend":"onnx",...} // {"recognizer_model":"adaface","agegender_backend":"onnx","emotion_backend":"onnx",...}
extern "C" ANSFR_API int GetANSRFModelInfo(ANSCENTER::ANSFacialRecognition** Handle, LStrHandle modelInfo); extern "C" ANSFR_API int GetANSRFModelInfo(ANSCENTER::ANSFacialRecognition** Handle, LStrHandle modelInfo);
// Slow-attribute (age/gender + emotions) refresh interval in frames per // 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 // cut the attribute-model GPU cost proportionally at the price of slower
// attribute updates — useful on smaller GPUs with the heavier v1.4 ONNX // attribute updates; lower it for the freshest attributes on GPUs with
// age-gender model. Returns 1 on success, -1 on invalid arguments. // headroom. Returns 1 on success, -1 on invalid arguments.
extern "C" ANSFR_API int SetANSRFAttributeInterval(ANSCENTER::ANSFacialRecognition** Handle, int frames); extern "C" ANSFR_API int SetANSRFAttributeInterval(ANSCENTER::ANSFacialRecognition** Handle, int frames);
+1 -1
View File
@@ -1991,7 +1991,7 @@ int ClassroomAttributesVideoTest()
static void RunSinglePackBenchmark(const std::string& label, static void RunSinglePackBenchmark(const std::string& label,
const std::string& modelZip, const std::string& dbFolder, const std::string& modelZip, const std::string& dbFolder,
int warmupFrames = 10, int measuredFrames = 100, 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 videoPath = "C:\\Programs\\DemoAssets\\Videos\\classroom.mp4";
const std::string detectorZip = kFaceDetectorZip; const std::string detectorZip = kFaceDetectorZip;