-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yolov11n and yolov11m added to model selection
- Loading branch information
1 parent
2c2dc7b
commit 38261e0
Showing
15 changed files
with
173 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# built-in dependencies | ||
from typing import Any | ||
|
||
# project dependencies | ||
from deepface.models.YoloModel import YoloModel, WEIGHT_URLS, WEIGHT_NAMES | ||
from deepface.commons import weight_utils | ||
from deepface.commons.logger import Logger | ||
|
||
logger = Logger() | ||
|
||
|
||
class YoloClientBase: | ||
def __init__(self, model: YoloModel): | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from enum import Enum | ||
|
||
|
||
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# built-in dependencies | ||
from typing import List | ||
|
||
# 3rd party dependencies | ||
import numpy as np | ||
|
||
# project dependencies | ||
from deepface.models.YoloClientBase import YoloClientBase | ||
from deepface.models.YoloModel import YoloModel | ||
from deepface.models.FacialRecognition import FacialRecognition | ||
from deepface.commons.logger import Logger | ||
|
||
logger = Logger() | ||
|
||
|
||
class YoloFacialRecognitionClient(YoloClientBase, FacialRecognition): | ||
def __init__(self, model: YoloModel): | ||
super().__init__(model) | ||
self.model_name = "Yolo" | ||
self.input_shape = None | ||
self.output_shape = 512 | ||
|
||
def forward(self, img: np.ndarray) -> List[float]: | ||
return self.model.embed(img)[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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.