ANSFR: persist explicit recognizer-model choice across restarts
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>
This commit is contained in:
@@ -237,6 +237,11 @@ namespace ANSCENTER
|
||||
// and what actually loaded (fallback may downgrade ADAFACE->ARCFACE).
|
||||
FaceRecognizerModel _requestedRecModel{ FaceRecognizerModel::ADAFACE };
|
||||
FaceRecognizerModel _activeRecModel{ FaceRecognizerModel::ADAFACE };
|
||||
// True once SetRecognizerModelType was called this session. An
|
||||
// explicit choice is persisted (RECOGNIZER_MODEL_PREF in the face
|
||||
// DB) and restored by LoadEngine on later runs; without it the
|
||||
// stored preference (if any) wins over the built-in default.
|
||||
bool _recModelExplicit{ false };
|
||||
const size_t QUEUE_SIZE = 10;
|
||||
const size_t FACE_THRESHOLD_SIZE = 5;
|
||||
// Cached attribute JSON per tracked face (everything except head pose).
|
||||
@@ -374,8 +379,10 @@ extern "C" ANSFR_API int GetFaceQueue(ANSCENTER::ANSFacialRecognition** Handl
|
||||
// after it to switch live — a live switch reloads the recognizer engine and
|
||||
// regenerates every stored face embedding from the enrolled face images
|
||||
// (embeddings produced by different models are not comparable), so it can
|
||||
// take a while on large databases. Returns 1 on success, 0 on failure, -1 on
|
||||
// invalid arguments.
|
||||
// take a while on large databases. The explicit choice is persisted in the
|
||||
// face database (RECOGNIZER_MODEL_PREF) and restored automatically on the
|
||||
// next LoadANSRFEngine, so it survives restarts without re-calling this.
|
||||
// Returns 1 on success, 0 on failure, -1 on invalid arguments.
|
||||
extern "C" ANSFR_API int SetANSRFRecognizerModel(ANSCENTER::ANSFacialRecognition** Handle, int modelType);
|
||||
// Returns the ACTIVE model (0 = AdaFace, 1 = ArcFace) or -1 on error. May
|
||||
// differ from what was requested when the model pack has no
|
||||
|
||||
Reference in New Issue
Block a user