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:
@@ -1802,6 +1802,19 @@ int TestModelSwitchV14()
|
||||
std::cout << "Model info: " << h->GetActiveModelInfo() << std::endl;
|
||||
recognizesUser("recognized after switch to ArcFace");
|
||||
|
||||
// --- persistence: the explicit ArcFace choice must survive a restart ---
|
||||
ReleaseANSRFHandle(&h);
|
||||
h = nullptr;
|
||||
{
|
||||
int cr2 = CreateANSRFHandle(&h, "", "", dbFile.c_str(), modelZip.c_str(), detectorZip.c_str(),
|
||||
0, 0.35f, 1, 1, 1, 30, 0.5f, 0, 0);
|
||||
V14Check(cr2 > 0 && h != nullptr, "re-create handle (simulated restart)", failures);
|
||||
V14Check(LoadANSRFEngine(&h) == 1, "reload engine after restart", failures);
|
||||
V14Check(GetANSRFRecognizerModel(&h) == 1,
|
||||
"persisted ArcFace choice restored after restart", failures);
|
||||
recognizesUser("recognized after restart with persisted ArcFace");
|
||||
}
|
||||
|
||||
// --- and back to AdaFace ------------------------------------------------
|
||||
V14Check(SetANSRFRecognizerModel(&h, 0) == 1, "switch back to AdaFace", failures);
|
||||
V14Check(GetANSRFRecognizerModel(&h) == 0, "active model is AdaFace (0)", failures);
|
||||
@@ -2206,6 +2219,11 @@ int main(int argc, char** argv)
|
||||
return TestOutputFormatParity();
|
||||
}
|
||||
|
||||
// v1.4 model-switch + persistence test: ANSFR-UnitTest.exe --test
|
||||
if (argc >= 2 && std::string(argv[1]) == "--test") {
|
||||
return TestModelSwitchV14();
|
||||
}
|
||||
|
||||
// Single-pack benchmark mode (one pack per process so the packs cannot
|
||||
// influence each other): ANSFR-UnitTest.exe --bench old|new|both
|
||||
if (argc >= 3 && std::string(argv[1]) == "--bench") {
|
||||
|
||||
Reference in New Issue
Block a user