MCPcopy Create free account
hub / github.com/CScorza/IntelOSINT / compare_faces_arcface

Method compare_faces_arcface

IntelOSINT.py:10792–11111  ·  view source on GitHub ↗
(self, image_a=None, image_b=None, threshold=(0.55 + 0.36) / 1.36, images_a=None, images_b=None, mode="pair", provider="arcface")

Source from the content-addressed store, hash-verified

10790 return v / n
10791
10792 def compare_faces_arcface(self, image_a=None, image_b=None, threshold=(0.55 + 0.36) / 1.36, images_a=None, images_b=None, mode="pair", provider="arcface"):
10793 try:
10794 import numpy as np
10795 except Exception as e:
10796 return {"error": f"Libreria mancante: numpy ({e})"}
10797
10798 try:
10799 try:
10800 threshold = float(threshold)
10801 except Exception:
10802 threshold = (0.55 + 0.36) / 1.36
10803 mode = str(mode or "pair").lower().strip()
10804 provider_raw = str(provider or "arcface").lower().strip()
10805 provider_alias = {
10806 "ukface": "uk",
10807 "uk-face": "uk",
10808 "uk face": "uk",
10809 "uk face recognition": "uk",
10810 "uk_face": "uk",
10811 "uk_face_recognition": "uk",
10812 "uk recognition": "uk",
10813 "ukrec": "uk",
10814 "face recognition uk": "uk",
10815 "face-recognition-uk": "uk",
10816 "arcface": "arcface",
10817 "arc": "arcface",
10818 "arc-face": "arcface",
10819 }
10820 provider_id = provider_alias.get(provider_raw, provider_raw)
10821 if provider_id not in {"arcface", "uk", "uk-face", "uk-recognition"}:
10822 provider_id = "arcface"
10823 mode_alias = {
10824 "1:1": "pair",
10825 "1:tanti": "one_to_many",
10826 "one-to-many": "one_to_many",
10827 "many": "many_to_many",
10828 "many_to_many": "many_to_many",
10829 }
10830 if mode in mode_alias:
10831 mode = mode_alias[mode]
10832 if mode not in {"pair", "one_to_many", "many_to_many"}:
10833 return {"error": "Modalità confronto non valida (usa 'pair', 'one_to_many' o 'many_to_many')."}
10834
10835 if images_a is None:
10836 images_a = [image_a] if image_a else []
10837 elif not isinstance(images_a, (list, tuple)):
10838 images_a = [images_a]
10839 if images_b is None:
10840 images_b = [image_b] if image_b else []
10841 elif not isinstance(images_b, (list, tuple)):
10842 images_b = [images_b]
10843 images_a = [x for x in images_a if isinstance(x, str) and x.strip()]
10844 images_b = [x for x in images_b if isinstance(x, str) and x.strip()]
10845
10846 max_images = 8
10847 if len(images_a) == 0 or len(images_b) == 0:
10848 return {"error": "Seleziona almeno un'immagine per ciascun lato."}
10849 if mode == "pair" and (len(images_a) != 1 or len(images_b) != 1):

Callers 1

face_compareFunction · 0.80

Calls 1

_face_init_engineMethod · 0.95

Tested by

no test coverage detected