mirror of
https://github.com/serengil/deepface.git
synced 2025-06-08 04:25:21 +00:00
Add Dataclass
This commit is contained in:
parent
47e0bf18d1
commit
8bf60a8d5e
@ -1,6 +1,7 @@
|
|||||||
from typing import List, Tuple, Optional
|
from typing import List, Tuple, Optional
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
# Notice that all facial detector models must be inherited from this class
|
# Notice that all facial detector models must be inherited from this class
|
||||||
|
|
||||||
@ -27,63 +28,42 @@ class Detector(ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
class FacialAreaRegion:
|
class FacialAreaRegion:
|
||||||
|
"""
|
||||||
|
Initialize a Face object.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
x (int): The x-coordinate of the top-left corner of the bounding box.
|
||||||
|
y (int): The y-coordinate of the top-left corner of the bounding box.
|
||||||
|
w (int): The width of the bounding box.
|
||||||
|
h (int): The height of the bounding box.
|
||||||
|
left_eye (tuple): The coordinates (x, y) of the left eye with respect to
|
||||||
|
the person instead of observer. Default is None.
|
||||||
|
right_eye (tuple): The coordinates (x, y) of the right eye with respect to
|
||||||
|
the person instead of observer. Default is None.
|
||||||
|
confidence (float, optional): Confidence score associated with the face detection.
|
||||||
|
Default is None.
|
||||||
|
"""
|
||||||
x: int
|
x: int
|
||||||
y: int
|
y: int
|
||||||
w: int
|
w: int
|
||||||
h: int
|
h: int
|
||||||
left_eye: Tuple[int, int]
|
left_eye: Optional[Tuple[int, int]] = None
|
||||||
right_eye: Tuple[int, int]
|
right_eye: Optional[Tuple[int, int]] = None
|
||||||
confidence: float
|
confidence: Optional[float] = None
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
x: int,
|
|
||||||
y: int,
|
|
||||||
w: int,
|
|
||||||
h: int,
|
|
||||||
left_eye: Optional[Tuple[int, int]] = None,
|
|
||||||
right_eye: Optional[Tuple[int, int]] = None,
|
|
||||||
confidence: Optional[float] = None,
|
|
||||||
):
|
|
||||||
"""
|
|
||||||
Initialize a Face object.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
x (int): The x-coordinate of the top-left corner of the bounding box.
|
|
||||||
y (int): The y-coordinate of the top-left corner of the bounding box.
|
|
||||||
w (int): The width of the bounding box.
|
|
||||||
h (int): The height of the bounding box.
|
|
||||||
left_eye (tuple): The coordinates (x, y) of the left eye with respect to
|
|
||||||
the person instead of observer. Default is None.
|
|
||||||
right_eye (tuple): The coordinates (x, y) of the right eye with respect to
|
|
||||||
the person instead of observer. Default is None.
|
|
||||||
confidence (float, optional): Confidence score associated with the face detection.
|
|
||||||
Default is None.
|
|
||||||
"""
|
|
||||||
self.x = x
|
|
||||||
self.y = y
|
|
||||||
self.w = w
|
|
||||||
self.h = h
|
|
||||||
self.left_eye = left_eye
|
|
||||||
self.right_eye = right_eye
|
|
||||||
self.confidence = confidence
|
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
class DetectedFace:
|
class DetectedFace:
|
||||||
|
"""
|
||||||
|
Initialize detected face object.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
img (np.ndarray): detected face image as numpy array
|
||||||
|
facial_area (FacialAreaRegion): detected face's metadata (e.g. bounding box)
|
||||||
|
confidence (float): confidence score for face detection
|
||||||
|
"""
|
||||||
img: np.ndarray
|
img: np.ndarray
|
||||||
facial_area: FacialAreaRegion
|
facial_area: FacialAreaRegion
|
||||||
confidence: float
|
confidence: float
|
||||||
|
|
||||||
def __init__(self, img: np.ndarray, facial_area: FacialAreaRegion, confidence: float):
|
|
||||||
"""
|
|
||||||
Initialize detected face object.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
img (np.ndarray): detected face image as numpy array
|
|
||||||
facial_area (FacialAreaRegion): detected face's metadata (e.g. bounding box)
|
|
||||||
confidence (float): confidence score for face detection
|
|
||||||
"""
|
|
||||||
self.img = img
|
|
||||||
self.facial_area = facial_area
|
|
||||||
self.confidence = confidence
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user