12 KiB
graph LR
Face_Detection_Models["Face Detection Models"]
Facial_Recognition_Models["Facial Recognition Models"]
Demography_Models["Demography Models"]
Anti_Spoofing_Model_FasNet_["Anti-Spoofing Model (FasNet)"]
Weight_Management_Utility["Weight Management Utility"]
Facial_Area_Region_Data_Structure["Facial Area Region Data Structure"]
Face_Detection_Models -- "relies on" --> Weight_Management_Utility
Face_Detection_Models -- "produces" --> Facial_Area_Region_Data_Structure
Facial_Recognition_Models -- "relies on" --> Weight_Management_Utility
Demography_Models -- "relies on" --> Weight_Management_Utility
Demography_Models -- "relies on" --> Facial_Recognition_Models
Anti_Spoofing_Model_FasNet_ -- "relies on" --> Weight_Management_Utility
Details
This subsystem encapsulates the core deep learning functionalities of deepface
, providing specialized models for various facial analysis tasks. It is structured around distinct model types, a central utility for managing model weights, and a standardized data structure for detected faces.
Face Detection Models
This component provides a collection of algorithms and models for accurately detecting human faces within images. Each specific detection model (e.g., CenterFaceClient, DlibClient, MediaPipeClient, OpenCvClient, YoloDetectorClient, YuNetClient, etc.) is implemented as a client class, all inheriting from the deepface.models.Detector.Detector
base class. This design ensures a unified interface for face detection operations, consistently returning structured FacialAreaRegion
data.
Related Classes/Methods:
deepface.models.Detector.Detector
(9:27)deepface.models.face_detection.CenterFace.CenterFaceClient
(20:85)deepface.models.face_detection.Dlib.DlibClient
(15:104)deepface.models.face_detection.MediaPipe.MediaPipeClient
(11:96)deepface.models.face_detection.OpenCv.OpenCvClient
(12:175)deepface.models.face_detection.Yolo.YoloDetectorClient
(36:121)deepface.models.face_detection.YuNet.YuNetClient
(19:129)
Facial Recognition Models
This component offers multiple pre-trained deep learning models designed for facial recognition, capable of generating high-dimensional embeddings (numerical representations) from face images. These embeddings are essential for tasks such as face verification (determining if two faces belong to the same person) or identification. Each model (e.g., ArcFaceClient, FaceNet128dClient, VggFaceClient, DeepIdClient, GhostFaceNetClient, OpenFaceClient, SFaceClient, DlibClient, Buffalo_L, DeepFaceClient) is represented by a client class inheriting from the deepface.models.FacialRecognition.FacialRecognition
base class.
Related Classes/Methods:
deepface.models.FacialRecognition.FacialRecognition
(15:47)deepface.models.facial_recognition.ArcFace.ArcFaceClient
(47:56)deepface.models.facial_recognition.Facenet.FaceNet128dClient
(52:61)deepface.models.facial_recognition.VggFace.VggFaceClient
(1:1)deepface.models.facial_recognition.DeepId.DeepIdClient
(1:1)deepface.models.facial_recognition.GhostFaceNet.GhostFaceNetClient
(53:66)deepface.models.facial_recognition.OpenFace.OpenFaceClient
(31:40)deepface.models.facial_recognition.SFace.SFaceClient
(18:49)deepface.models.facial_recognition.Dlib.DlibClient
(17:55)deepface.models.facial_recognition.Buffalo_L.Buffalo_L
(10:94)deepface.models.facial_recognition.DeepFace.DeepFaceClient
(1:1)
Demography Models
This component specializes in analyzing demographic attributes of detected faces, including age, emotion, gender, and race. It comprises specialized client classes (ApparentAgeClient, EmotionClient, GenderClient, RaceClient), all inheriting from the deepface.models.Demography.Demography
base class. These models preprocess input, perform internal predictions, and derive demographic insights. Notably, the age, gender, and race prediction models leverage the VGGFaceClient from the Facial Recognition Models component for feature extraction.
Related Classes/Methods:
deepface.models.Demography.Demography
(15:67)deepface.models.demography.Age.ApparentAgeClient
(32:62)deepface.models.demography.Emotion.EmotionClient
(39:79)deepface.models.demography.Gender.GenderClient
(34:59)deepface.models.demography.Race.RaceClient
(33:59)
Anti-Spoofing Model (FasNet)
This component is dedicated to detecting presentation attacks (spoofing) by analyzing facial images to determine if a real person is present or if it's a fake (e.g., photo, video replay). It includes the core Fasnet
model and its associated backbone architectures (MiniFASNetV2
, MiniFASNetV1SE
), which are composed of various building blocks like Conv_block
, Depth_Wise
, Linear_block
, Residual
, and SEModule
defined within FasNetBackbone
.
Related Classes/Methods:
deepface.models.spoofing.FasNet.Fasnet
(17:139)deepface.models.spoofing.FasNetBackbone.MiniFASNetV2
(127:130)deepface.models.spoofing.FasNetBackbone.MiniFASNetV1SE
(133:138)deepface.models.spoofing.FasNetBackbone.Conv_block
(146:165)deepface.models.spoofing.FasNetBackbone.Depth_Wise
(188:213)deepface.models.spoofing.FasNetBackbone.Linear_block
(168:185)deepface.models.spoofing.FasNetBackbone.Residual
(278:301)deepface.models.spoofing.FasNetBackbone.SEModule
(255:275)
Weight Management Utility
This is a crucial utility component responsible for managing the lifecycle of pre-trained model weights. It handles downloading necessary weights from remote sources and loading them into the respective models, ensuring models are ready for inference. This component is fundamental as all other model components depend on it for initialization and operation.
Related Classes/Methods:
deepface.models.weight_utils
(1:1)
Facial Area Region Data Structure
This component defines a standardized data structure (FacialAreaRegion
), which inherits from DetectedFace
. It is used across the face detection and other related modules to encapsulate the results of face detection, including bounding box coordinates and potentially facial landmarks. It provides a consistent output format for all face detectors.
Related Classes/Methods: