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)
| 147 | |
| 148 | |
| 149 | def _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 ──────────────────────────────────────────────── |
no test coverage detected