{
  "model": "yunet-2023mar+sface-2021dec",
  "about": "How Face API computes gallery vectors. A local face gate that follows these steps with the same files and libraries produces vectors comparable with POST /export.",
  "runtime": { "python": "3.12", "opencv-python-headless": "4.14.0.94", "numpy": "2.5.3" },
  "detector": {
    "name": "YuNet",
    "file": "face_detection_yunet_2023mar.onnx",
    "url": "https://github.com/opencv/opencv_zoo/raw/main/models/face_detection_yunet/face_detection_yunet_2023mar.onnx",
    "sha256": "8f2383e4dd3cfbb4553ea8718107fc0423210dc964f9f4280604804ed2552fa4",
    "score_threshold": 0.8,
    "nms_threshold": 0.3,
    "top_k": 5000
  },
  "recognizer": {
    "name": "SFace",
    "file": "face_recognition_sface_2021dec.onnx",
    "url": "https://github.com/opencv/opencv_zoo/raw/main/models/face_recognition_sface/face_recognition_sface_2021dec.onnx",
    "sha256": "0ba9fbfa01b5270c96627c4ef784da859931e02f04419c829e83484087c34e79"
  },
  "preprocess": {
    "max_side": 640,
    "dominance": 2.0,
    "steps": [
      "Image as 8-bit BGR: cv2.imdecode(bytes, cv2.IMREAD_COLOR) for a file, or a cv2.VideoCapture frame as is.",
      "scale = max_side / max(height, width); only if scale < 1: cv2.resize(img, None, fx=scale, fy=scale, interpolation=cv2.INTER_AREA). Never upscale.",
      "detector = cv2.FaceDetectorYN.create(detector file, \"\", (320, 320), score_threshold, nms_threshold, top_k); detector.setInputSize((width, height)) of the resized image; _, faces = detector.detect(img).",
      "Exactly one face, as /identify requires: no face or more than one = no vector. (Gallery KYC selfies with several faces used the largest when its box area w*h is at least dominance times the second.)",
      "recognizer = cv2.FaceRecognizerSF.create(recognizer file, \"\"); vector = recognizer.feature(recognizer.alignCrop(img, faces[0])).flatten(): 128 float32, not normalized."
    ]
  },
  "vector": { "dims": 128, "dtype": "float32", "normalized": false },
  "score": "Cosine similarity, -1..1: dot(a, b) / (norm(a) * norm(b)). The same score /identify returns. A person's score is the best over all their vectors.",
  "decision": { "threshold": 0.6, "margin": 0.08, "rule": "Match only when the best person's score >= threshold and leads the second-best person's score by >= margin; otherwise unknown." }
}
