UniFace: A Unified Face Analysis Library for Python | Detection, alignment, landmarks, face-mesh, recognition, parsing, gaze, attributes and anti-spoofing under one API.
Python computer-visiondeep-learningface-alignmentface-analysisface-anonymizationface-anti-spoofingface-attributesface-detectionface-meshface-parsingface-quality-assessmentface-recognitionface-segmentationface-trackingfacial-landmarksgaze-estimationhead-pose-estimationonnxruntimeportrait-mattingpython
chore: Update docstrings and comments (#119)
Yakhyokhuja Valikhujaev7882ec5cb45f
diff --git a/uniface/detection/retinaface.py b/uniface/detection/retinaface.pyindex e7616a4..a46763e 100644--- a/uniface/detection/retinaface.py+++ b/uniface/detection/retinaface.py@@ -202,7 +202,7 @@ class RetinaFace(BaseDetector):height, width, _ = image.shapeimage_tensor = self.preprocess(image)- # ONNXRuntime inference+ # Inferenceoutputs = self.inference(image_tensor)# Postprocessingdiff --git a/uniface/detection/scrfd.py b/uniface/detection/scrfd.pyindex 9f781c1..f09c5d9 100644--- a/uniface/detection/scrfd.py+++ b/uniface/detection/scrfd.py@@ -247,9 +247,10 @@ class SCRFD(BaseDetector):image_tensor = self.preprocess(image)- # ONNXRuntime inference+ # Inferenceoutputs = self.inference(image_tensor)+ # Postprocessingscores_list, bboxes_list, kpss_list = self.postprocess(outputs, image_size=image.shape[:2])# Handle case when no faces are detecteddiff --git a/uniface/detection/yolov8.py b/uniface/detection/yolov8.pyindex c674c48..31def87 100644--- a/uniface/detection/yolov8.py+++ b/uniface/detection/yolov8.py@@ -2,13 +2,6 @@# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyo-"""-YOLOv8-Face detector implementation.--Uses anchor-free design with DFL (Distribution Focal Loss) for bbox regression.-Reference: https://github.com/yakhyo/yolov8-face-onnx-inference-"""-from typing import Any, Literalimport numpy as np@@ -273,16 +266,14 @@ class YOLOv8Face(BaseDetector):if len(keep) == 0:return np.array([]), np.array([])- # Limit to max_det+ # Filter detections and limit to max_detkeep = keep[: self.max_det]boxes = boxes[keep]scores = scores[keep]landmarks = landmarks[keep]- # === SCALE TO ORIGINAL IMAGE COORDINATES ===+ # Scale back to original image coordinatespad_w, pad_h = padding-- # Scale boxes back to original image coordinatesboxes[:, [0, 2]] = (boxes[:, [0, 2]] - pad_w) / scaleboxes[:, [1, 3]] = (boxes[:, [1, 3]] - pad_h) / scale@@ -297,7 +288,7 @@ class YOLOv8Face(BaseDetector):# Reshape landmarks to (N, 5, 2)landmarks = landmarks.reshape(-1, 5, 2)- # Combine box and score+ # Combine resultsdetections = np.concatenate([boxes, scores[:, None]], axis=1)return detections, landmarksdiff --git a/uniface/gaze/models.py b/uniface/gaze/models.pyindex eea5cc1..1f87147 100644--- a/uniface/gaze/models.py+++ b/uniface/gaze/models.py@@ -179,6 +179,13 @@ class MobileGaze(BaseGazeEstimator):This method orchestrates the full pipeline: preprocessing the input,running inference, and postprocessing to return the gaze direction.++ Args:+ face_image (np.ndarray): A cropped face image in BGR format with shape (H, W, 3).++ Returns:+ GazeResult: Estimated gaze direction containing ``pitch`` (vertical) and+ ``yaw`` (horizontal) angles in radians."""input_tensor = self.preprocess(face_image)outputs = self.session.run(self.output_names, {self.input_name: input_tensor})diff --git a/uniface/headpose/models.py b/uniface/headpose/models.pyindex 070287f..6352c8a 100644--- a/uniface/headpose/models.py+++ b/uniface/headpose/models.py@@ -170,6 +170,13 @@ class HeadPose(BaseHeadPoseEstimator):This method orchestrates the full pipeline: preprocessing the input,running inference, and postprocessing to return the head orientation.++ Args:+ face_image (np.ndarray): A cropped face image in BGR format with shape (H, W, 3).++ Returns:+ HeadPoseResult: Estimated head orientation containing ``pitch`` (vertical),+ ``yaw`` (horizontal), and ``roll`` (in-plane) angles in degrees."""input_tensor = self.preprocess(face_image)outputs = self.session.run(self.output_names, {self.input_name: input_tensor})