MCPcopy
hub / github.com/serengil/deepface / analysis

Function analysis

deepface/modules/streaming.py:28–223  ·  view source on GitHub ↗

Run real time face recognition and facial attribute analysis Args: db_path (string): Path to the folder containing image files. All detected faces in the database will be considered in the decision-making process. model_name (str): Model for face recognition. O

(
    db_path: str,
    model_name: str = "VGG-Face",
    detector_backend: str = "opencv",
    distance_metric: str = "cosine",
    enable_face_analysis: bool = True,
    source: int = 0,
    time_threshold: int = 5,
    frame_threshold: int = 5,
    anti_spoofing: bool = False,
    output_path: Optional[str] = None,
    debug: bool = False,
)

Source from the content-addressed store, hash-verified

26
27# pylint: disable=unused-variable, too-many-positional-arguments
28def analysis(
29 db_path: str,
30 model_name: str = "VGG-Face",
31 detector_backend: str = "opencv",
32 distance_metric: str = "cosine",
33 enable_face_analysis: bool = True,
34 source: int = 0,
35 time_threshold: int = 5,
36 frame_threshold: int = 5,
37 anti_spoofing: bool = False,
38 output_path: Optional[str] = None,
39 debug: bool = False,
40) -> None:
41 """
42 Run real time face recognition and facial attribute analysis
43
44 Args:
45 db_path (string): Path to the folder containing image files. All detected faces
46 in the database will be considered in the decision-making process.
47
48 model_name (str): Model for face recognition. Options: VGG-Face, Facenet, Facenet512,
49 OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace and GhostFaceNet (default is VGG-Face)
50
51 detector_backend (string): face detector backend. Options: 'opencv', 'retinaface',
52 'mtcnn', 'ssd', 'dlib', 'mediapipe', 'yolov8n', 'yolov8m', 'yolov8l', 'yolov11n',
53 'yolov11s', 'yolov11m', 'yolov11l', 'yolov12n', 'yolov12s', 'yolov12m', 'yolov12l'
54 'centerface' or 'skip' (default is opencv).
55
56 distance_metric (string): Metric for measuring similarity. Options: 'cosine',
57 'euclidean', 'euclidean_l2', 'angular' (default is cosine).
58
59 enable_face_analysis (bool): Flag to enable face analysis (default is True).
60
61 source (Any): The source for the video stream (default is 0, which represents the
62 default camera).
63
64 time_threshold (int): The time threshold (in seconds) for face recognition (default is 5).
65
66 frame_threshold (int): The frame threshold for face recognition (default is 5).
67
68 anti_spoofing (boolean): Flag to enable anti spoofing (default is False).
69
70 output_path (str): Path to save the output video. (default is None
71 If None, no video is saved).
72 Returns:
73 None
74 """
75 # initialize models
76 build_demography_models(enable_face_analysis=enable_face_analysis)
77 build_facial_recognition_model(model_name=model_name)
78 # call a dummy find function for db_path once to create embeddings before starting webcam
79 _ = search_identity(
80 detected_face=np.zeros([224, 224, 3]),
81 db_path=db_path,
82 detector_backend=detector_backend,
83 distance_metric=distance_metric,
84 model_name=model_name,
85 )

Callers

nothing calls this directly

Calls 12

build_demography_modelsFunction · 0.85
search_identityFunction · 0.85
grab_facial_areasFunction · 0.85
extract_facial_areasFunction · 0.85
highlight_facial_areasFunction · 0.85
countdown_to_freezeFunction · 0.85
countdown_to_releaseFunction · 0.85
errorMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected