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

Function _build_antispoofer

backend/python/insightface/engines.py:149–171  ·  view source on GitHub ↗

Instantiate an Antispoofer from option keys, or return None. Recognised options: antispoof_v2_onnx — path/filename of MiniFASNetV2 (scale 2.7) antispoof_v1se_onnx — path/filename of MiniFASNetV1SE (scale 4.0) antispoof_threshold — real-class probability threshold

(options: dict[str, str], model_dir: str | None)

Source from the content-addressed store, hash-verified

147
148
149def _build_antispoofer(options: dict[str, str], model_dir: str | None) -> Antispoofer | None:
150 """Instantiate an Antispoofer from option keys, or return None.
151
152 Recognised options:
153 antispoof_v2_onnx — path/filename of MiniFASNetV2 (scale 2.7)
154 antispoof_v1se_onnx — path/filename of MiniFASNetV1SE (scale 4.0)
155 antispoof_threshold — real-class probability threshold, default 0.5
156
157 Either or both can be provided. Returns None when neither is set.
158 """
159 pairs: list[tuple[str, float]] = []
160 v2 = options.get("antispoof_v2_onnx", "")
161 if v2:
162 pairs.append((_resolve_model_path(v2, model_dir=model_dir), 2.7))
163 v1se = options.get("antispoof_v1se_onnx", "")
164 if v1se:
165 pairs.append((_resolve_model_path(v1se, model_dir=model_dir), 4.0))
166 if not pairs:
167 return None
168 threshold = float(options.get("antispoof_threshold", "0.5"))
169 spoofer = Antispoofer()
170 spoofer.load(pairs, threshold=threshold)
171 return spoofer
172
173
174# ─── InsightFaceEngine ────────────────────────────────────────────────

Callers 2

prepareMethod · 0.85
prepareMethod · 0.85

Calls 5

loadMethod · 0.95
_resolve_model_pathFunction · 0.85
AntispooferClass · 0.85
appendMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected