MCPcopy
hub / github.com/mudler/LocalAI / prepare

Method prepare

backend/python/insightface/engines.py:395–419  ·  view source on GitHub ↗
(self, options: dict[str, str])

Source from the content-addressed store, hash-verified

393 self._antispoofer: Antispoofer | None = None
394
395 def prepare(self, options: dict[str, str]) -> None:
396 raw_det = options.get("detector_onnx", "")
397 raw_rec = options.get("recognizer_onnx", "")
398 if not raw_det or not raw_rec:
399 raise ValueError(
400 "onnx_direct engine requires both detector_onnx and recognizer_onnx options"
401 )
402 model_dir = options.get("_model_dir")
403 self.detector_path = _resolve_model_path(raw_det, model_dir=model_dir)
404 self.recognizer_path = _resolve_model_path(raw_rec, model_dir=model_dir)
405 self.input_size = _parse_det_size(options.get("det_size", "320x320"))
406 self.det_thresh = float(options.get("det_thresh", "0.5"))
407 self._antispoofer = _build_antispoofer(options, model_dir)
408
409 # YuNet is a fixed-size detector; size is reset per detect() call to
410 # match the input frame.
411 self._detector = cv2.FaceDetectorYN.create(
412 self.detector_path,
413 "",
414 self.input_size,
415 score_threshold=self.det_thresh,
416 nms_threshold=0.3,
417 top_k=5000,
418 )
419 self._recognizer = cv2.FaceRecognizerSF.create(self.recognizer_path, "")
420
421 def detect(self, img: np.ndarray) -> list[FaceDetection]:
422 if self._detector is None:

Callers

nothing calls this directly

Calls 5

_resolve_model_pathFunction · 0.85
_parse_det_sizeFunction · 0.85
_build_antispooferFunction · 0.85
getMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected