Skip to content

Stop the scan when a model gives NaN instead of counting it as a pass - #9

Merged
L0adn9 merged 1 commit into
L0adn9:mainfrom
amanmprojects:fix/nan-model-scores
Nov 6, 2026
Merged

L0adn9 merged 1 commit into
L0adn9:mainfrom
amanmprojects:fix/nan-model-scores

Conversation

@amanmprojects

Copy link
Copy Markdown
Contributor

This is the small PR you asked for in #7: the NaN liveness fix on its own, rebased on 1.2.2.

Each scan check compares a model reading against a limit, and NaN fails every comparison. A NaN liveness score failed live < Liveness::kLive, so on a webcam it counted as live. The attention check has the same hole: a NaN head pose or gaze got past > 0.2, < -kGazeDown and the rest, and came back "ok".

Now a reading that is not a number ends the scan with RESULT error models. The camera turns off, the status goes to unavailable and PAM asks for the password. Nothing counts toward the lockout.

The second part: an OpenCV exception thrown during a scan (for example a model that cannot run on its input) used to abort the engine and dump core. serve now catches cv::Exception and answers error models. PAM fell back to the password before as well, so the change is a prompt answer and no core dump.

Identity scores are left alone. In 1.2.2 bestScore skips an appearance whose mean is NaN (mean > best is false), so a NaN never reaches the threshold.

Validation

  • make with the repo's -Wall -Wextra flags: no warnings. omaface-engine selftest passes with the new binary.
  • A harness built against the 1.2.2 engine and this branch called Attention::check with a real face model load and a NaN head pose:
    • 1.2.2: ok
    • this branch: models
  • I did not run a camera scan with a model forced to give NaN.

Created with Claude Opus 5.5 in Claude Code.

Each check compares a model reading against a limit, and NaN fails every
comparison. A NaN liveness score failed `live < kLive` and counted as
live; a NaN head pose or gaze came out of the attention check as "ok".
Both now end the scan with "error models", so the password is asked for.

An OpenCV exception during a scan aborted the engine and dumped core;
it now answers "error models" too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@L0adn9

L0adn9 commented Nov 6, 2026

Copy link
Copy Markdown
Owner

thanks for splitting this out! merging it into the hotfix with #8

@L0adn9
L0adn9 merged commit 20ca301 into L0adn9:main Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants