mirror of
https://github.com/serengil/deepface.git
synced 2025-06-07 12:05:22 +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,25 +28,8 @@ class Detector(ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
class FacialAreaRegion:
|
class FacialAreaRegion:
|
||||||
x: int
|
|
||||||
y: int
|
|
||||||
w: int
|
|
||||||
h: int
|
|
||||||
left_eye: Tuple[int, int]
|
|
||||||
right_eye: Tuple[int, int]
|
|
||||||
confidence: float
|
|
||||||
|
|
||||||
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.
|
Initialize a Face object.
|
||||||
|
|
||||||
@ -61,21 +45,17 @@ class FacialAreaRegion:
|
|||||||
confidence (float, optional): Confidence score associated with the face detection.
|
confidence (float, optional): Confidence score associated with the face detection.
|
||||||
Default is None.
|
Default is None.
|
||||||
"""
|
"""
|
||||||
self.x = x
|
x: int
|
||||||
self.y = y
|
y: int
|
||||||
self.w = w
|
w: int
|
||||||
self.h = h
|
h: int
|
||||||
self.left_eye = left_eye
|
left_eye: Optional[Tuple[int, int]] = None
|
||||||
self.right_eye = right_eye
|
right_eye: Optional[Tuple[int, int]] = None
|
||||||
self.confidence = confidence
|
confidence: Optional[float] = None
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
class DetectedFace:
|
class DetectedFace:
|
||||||
img: np.ndarray
|
|
||||||
facial_area: FacialAreaRegion
|
|
||||||
confidence: float
|
|
||||||
|
|
||||||
def __init__(self, img: np.ndarray, facial_area: FacialAreaRegion, confidence: float):
|
|
||||||
"""
|
"""
|
||||||
Initialize detected face object.
|
Initialize detected face object.
|
||||||
|
|
||||||
@ -84,6 +64,6 @@ class DetectedFace:
|
|||||||
facial_area (FacialAreaRegion): detected face's metadata (e.g. bounding box)
|
facial_area (FacialAreaRegion): detected face's metadata (e.g. bounding box)
|
||||||
confidence (float): confidence score for face detection
|
confidence (float): confidence score for face detection
|
||||||
"""
|
"""
|
||||||
self.img = img
|
img: np.ndarray
|
||||||
self.facial_area = facial_area
|
facial_area: FacialAreaRegion
|
||||||
self.confidence = confidence
|
confidence: float
|
||||||
|
Loading…
x
Reference in New Issue
Block a user