diff --git a/deepface/DeepFace.py b/deepface/DeepFace.py index cf2c827..b192ce0 100644 --- a/deepface/DeepFace.py +++ b/deepface/DeepFace.py @@ -54,8 +54,7 @@ def build_model(model_name: str, task: str = "facial_recognition") -> Any: Args: model_name (str): model identifier - VGG-Face, Facenet, Facenet512, OpenFace, DeepFace, DeepID, Dlib, - ArcFace, SFace, GhostFaceNet, Yolov8, Yolov11n, Yolov11s and - Yolov11m for face recognition + ArcFace, SFace and GhostFaceNet for face recognition - Age, Gender, Emotion, Race for facial attributes - opencv, mtcnn, ssd, dlib, retinaface, mediapipe, yolov8, yolov11n, yolov11s, yolov11m, yunet, fastmtcnn or centerface for face detectors @@ -94,8 +93,7 @@ def verify( or pre-calculated embeddings. model_name (str): Model for face recognition. Options: VGG-Face, Facenet, Facenet512, - OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace, GhostFaceNet, Yolov8, Yolov11n, - Yolov11s and Yolov11m (default is VGG-Face). + OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace and GhostFaceNet (default is VGG-Face). detector_backend (string): face detector backend. Options: 'opencv', 'retinaface', 'mtcnn', 'ssd', 'dlib', 'mediapipe', 'yolov8', 'yolov11n', 'yolov11s', 'yolov11m', 'centerface' or 'skip' @@ -291,8 +289,7 @@ def find( in the database will be considered in the decision-making process. model_name (str): Model for face recognition. Options: VGG-Face, Facenet, Facenet512, - OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace, GhostFaceNet, Yolov8, Yolov11n, - Yolov11s and Yolov11m (default is VGG-Face). + OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace and GhostFaceNet (default is VGG-Face). distance_metric (string): Metric for measuring similarity. Options: 'cosine', 'euclidean', 'euclidean_l2' (default is cosine). @@ -391,8 +388,7 @@ def represent( include information for each detected face. model_name (str): Model for face recognition. Options: VGG-Face, Facenet, Facenet512, - OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace, GhostFaceNet, Yolov8, Yolov11n, - Yolov11s and Yolov11m (default is VGG-Face.). + OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace and GhostFaceNet (default is VGG-Face.). enforce_detection (boolean): If no face is detected in an image, raise an exception. Default is True. Set to False to avoid the exception for low-resolution images @@ -462,8 +458,7 @@ def stream( in the database will be considered in the decision-making process. model_name (str): Model for face recognition. Options: VGG-Face, Facenet, Facenet512, - OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace, GhostFaceNet, Yolov8, Yolov11n, - Yolov11s and Yolov11m (default is VGG-Face). + OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace and GhostFaceNet (default is VGG-Face). detector_backend (string): face detector backend. Options: 'opencv', 'retinaface', 'mtcnn', 'ssd', 'dlib', 'mediapipe', 'yolov8', 'yolov11n', 'yolov11s', 'yolov11m', diff --git a/deepface/models/facial_recognition/Yolo.py b/deepface/models/facial_recognition/Yolo.py deleted file mode 100644 index b87f8fc..0000000 --- a/deepface/models/facial_recognition/Yolo.py +++ /dev/null @@ -1,88 +0,0 @@ -# built-in dependencies -from typing import List, Any -from enum import Enum - -# 3rd party dependencies -import numpy as np - -# project dependencies -from deepface.models.FacialRecognition import FacialRecognition -from deepface.commons.logger import Logger -from deepface.commons import weight_utils - -logger = Logger() - - -class YoloModel(Enum): - V8N = 0 - V11N = 1 - V11S = 2 - V11M = 3 - - -# Model's weights paths -WEIGHT_NAMES = ["yolov8n-face.pt", - "yolov11n-face.pt", - "yolov11s-face.pt", - "yolov11m-face.pt"] - -# Google Drive URL from repo (https://github.com/derronqi/yolov8-face) ~6MB -WEIGHT_URLS = ["https://drive.google.com/uc?id=1qcr9DbgsX3ryrz2uU8w4Xm3cOrRywXqb", - "https://github.com/akanametov/yolo-face/releases/download/v0.0.0/yolov11n-face.pt", - "https://github.com/akanametov/yolo-face/releases/download/v0.0.0/yolov11s-face.pt", - "https://github.com/akanametov/yolo-face/releases/download/v0.0.0/yolov11m-face.pt"] - - -class YoloFacialRecognitionClient(FacialRecognition): - def __init__(self, model: YoloModel): - super().__init__() - self.model_name = "Yolo" - self.input_shape = (640, 640) - self.output_shape = 512 - self.model = self.build_model(model) - - def build_model(self, model: YoloModel) -> Any: - """ - Build a yolo detector model - Returns: - model (Any) - """ - - # Import the optional Ultralytics YOLO model - try: - from ultralytics import YOLO - except ModuleNotFoundError as e: - raise ImportError( - "Yolo is an optional detector, ensure the library is installed. " - "Please install using 'pip install ultralytics'" - ) from e - - weight_file = weight_utils.download_weights_if_necessary( - file_name=WEIGHT_NAMES[model.value], source_url=WEIGHT_URLS[model.value] - ) - - # Return face_detector - return YOLO(weight_file) - - def forward(self, img: np.ndarray) -> List[float]: - return self.model.embed(np.squeeze(img, axis=0))[0].tolist() - - -class YoloFacialRecognitionClientV8n(YoloFacialRecognitionClient): - def __init__(self): - super().__init__(YoloModel.V8N) - - -class YoloFacialRecognitionClientV11n(YoloFacialRecognitionClient): - def __init__(self): - super().__init__(YoloModel.V11N) - - -class YoloFacialRecognitionClientV11s(YoloFacialRecognitionClient): - def __init__(self): - super().__init__(YoloModel.V11S) - - -class YoloFacialRecognitionClientV11m(YoloFacialRecognitionClient): - def __init__(self): - super().__init__(YoloModel.V11M) diff --git a/deepface/modules/modeling.py b/deepface/modules/modeling.py index 57a5e76..e12804e 100644 --- a/deepface/modules/modeling.py +++ b/deepface/modules/modeling.py @@ -11,8 +11,7 @@ from deepface.models.facial_recognition import ( SFace, Dlib, Facenet, - GhostFaceNet, - Yolo as YoloFacialRecognition, + GhostFaceNet ) from deepface.models.face_detection import ( FastMtCnn, @@ -37,7 +36,7 @@ def build_model(task: str, model_name: str) -> Any: task (str): facial_recognition, facial_attribute, face_detector, spoofing model_name (str): model identifier - VGG-Face, Facenet, Facenet512, OpenFace, DeepFace, DeepID, Dlib, - ArcFace, SFace, GhostFaceNet, Yolov8, Yolov11n, Yolov11s and Yolov11m for face recognition + ArcFace, SFace and GhostFaceNet for face recognition - Age, Gender, Emotion, Race for facial attributes - opencv, mtcnn, ssd, dlib, retinaface, mediapipe, yolov8, 'yolov11n', 'yolov11s', 'yolov11m', yunet, fastmtcnn or centerface for face detectors @@ -60,11 +59,7 @@ def build_model(task: str, model_name: str) -> Any: "Dlib": Dlib.DlibClient, "ArcFace": ArcFace.ArcFaceClient, "SFace": SFace.SFaceClient, - "GhostFaceNet": GhostFaceNet.GhostFaceNetClient, - "Yolov8": YoloFacialRecognition.YoloFacialRecognitionClientV8n, - "Yolov11n": YoloFacialRecognition.YoloFacialRecognitionClientV11n, - "Yolov11s": YoloFacialRecognition.YoloFacialRecognitionClientV11s, - "Yolov11m": YoloFacialRecognition.YoloFacialRecognitionClientV11m + "GhostFaceNet": GhostFaceNet.GhostFaceNetClient }, "spoofing": { "Fasnet": FasNet.Fasnet, diff --git a/deepface/modules/recognition.py b/deepface/modules/recognition.py index 25b3645..1edb430 100644 --- a/deepface/modules/recognition.py +++ b/deepface/modules/recognition.py @@ -45,8 +45,7 @@ def find( in the database will be considered in the decision-making process. model_name (str): Model for face recognition. Options: VGG-Face, Facenet, Facenet512, - OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace, GhostFaceNet, Yolov8, Yolov11n, - Yolov11s and Yolov11m (default is VGG-Face). + OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace and GhostFaceNet (default is VGG-Face). distance_metric (string): Metric for measuring similarity. Options: 'cosine', 'euclidean', 'euclidean_l2'. @@ -361,8 +360,7 @@ def __find_bulk_embeddings( employees (list): list of exact image paths model_name (str): Model for face recognition. Options: VGG-Face, Facenet, Facenet512, - OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace, GhostFaceNet, Yolov8, Yolov11n, - Yolov11s and Yolov11m (default is VGG-Face). + OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace and GhostFaceNet (default is VGG-Face). detector_backend (str): face detector model name @@ -477,8 +475,7 @@ def find_batched( (used for anti-spoofing). model_name (str): Model for face recognition. Options: VGG-Face, Facenet, Facenet512, - OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace, GhostFaceNet, Yolov8, Yolov11n, - Yolov11s and Yolov11m (default is VGG-Face). + OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace and GhostFaceNet (default is VGG-Face). distance_metric (string): Metric for measuring similarity. Options: 'cosine', 'euclidean', 'euclidean_l2'. diff --git a/deepface/modules/representation.py b/deepface/modules/representation.py index b8fcd29..c1e2a5f 100644 --- a/deepface/modules/representation.py +++ b/deepface/modules/representation.py @@ -30,7 +30,7 @@ def represent( include information for each detected face. model_name (str): Model for face recognition. Options: VGG-Face, Facenet, Facenet512, - OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace, GhostFaceNet, Yolov8, Yolov11n, Yolov11s and Yolov11m + OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace and GhostFaceNet enforce_detection (boolean): If no face is detected in an image, raise an exception. Default is True. Set to False to avoid the exception for low-resolution images. diff --git a/deepface/modules/streaming.py b/deepface/modules/streaming.py index 21cc6e7..cc44783 100644 --- a/deepface/modules/streaming.py +++ b/deepface/modules/streaming.py @@ -42,8 +42,7 @@ def analysis( in the database will be considered in the decision-making process. model_name (str): Model for face recognition. Options: VGG-Face, Facenet, Facenet512, - OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace, GhostFaceNet, Yolov8, Yolov11n, - Yolov11s and Yolov11m (default is VGG-Face). + OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace and GhostFaceNet (default is VGG-Face) detector_backend (string): face detector backend. Options: 'opencv', 'retinaface', 'mtcnn', 'ssd', 'dlib', 'mediapipe', 'yolov8', 'yolov11n', 'yolov11s', 'yolov11m', @@ -191,8 +190,7 @@ def search_identity( 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. Options: VGG-Face, Facenet, Facenet512, - OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace, GhostFaceNet, Yolov8, Yolov11n, - Yolov11s and Yolov11m (default is VGG-Face). + OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace and GhostFaceNet (default is VGG-Face). detector_backend (string): face detector backend. Options: 'opencv', 'retinaface', 'mtcnn', 'ssd', 'dlib', 'mediapipe', 'yolov8', 'yolov11n', 'yolov11s', 'yolov11m', 'centerface' or 'skip' (default is opencv). diff --git a/deepface/modules/verification.py b/deepface/modules/verification.py index 83b6f98..43c3ba9 100644 --- a/deepface/modules/verification.py +++ b/deepface/modules/verification.py @@ -44,8 +44,7 @@ def verify( or pre-calculated embeddings. model_name (str): Model for face recognition. Options: VGG-Face, Facenet, Facenet512, - OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace, GhostFaceNet, Yolov8, Yolov11n, - Yolov11s and Yolov11m (default is VGG-Face). + OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace and GhostFaceNet (default is VGG-Face). detector_backend (string): face detector backend. Options: 'opencv', 'retinaface', 'mtcnn', 'ssd', 'dlib', 'mediapipe', 'yolov8', 'yolov11n', 'yolov11s', 'yolov11m',