feat: Add usage examples for face detection and face alignment

This commit is contained in:
yakhyo
2024-11-21 05:55:55 +00:00
parent a158e47f52
commit 12ccac11b7
5 changed files with 231 additions and 5 deletions

View File

@@ -12,7 +12,7 @@
</div>
**uniface** is a lightweight face detection library designed for high-performance face localization and landmark detection. The library supports ONNX models and provides utilities for bounding box visualization and landmark plotting. To train RetinaFace model, see https://github.com/yakhyo/retinaface-pytorch.
**uniface** is a lightweight face detection library designed for high-performance face localization, landmark detection and face alignment. The library supports ONNX models and provides utilities for bounding box visualization and landmark plotting. To train RetinaFace model, see https://github.com/yakhyo/retinaface-pytorch.
---
@@ -47,6 +47,19 @@ pip install .
## Quick Start
To get started with face detection using **UniFace**, check out the [example notebook](examples/face_detection.ipynb).
It demonstrates how to initialize the model, run inference, and visualize the results.
---
## Examples
Explore the following example notebooks to learn how to use **UniFace** effectively:
- [Face Detection](examples/face_detection.ipynb): Demonstrates how to perform face detection, draw bounding boxes, and landmarks on an image.
- [Face Alignment](examples/face_alignment.ipynb): Shows how to align faces using detected landmarks.
- [Age and Gender Detection](examples/age_gender.ipynb): Example for detecting age and gender from faces. (underdevelopment)
### Initialize the Model
```python

File diff suppressed because one or more lines are too long

View File

@@ -5,7 +5,7 @@
"metadata": {},
"source": [
"## Example Usage of UniFace Library\n",
"This guide demonstrates how to use the **UniFace** library for face detection and visualization in a Jupyter Notebook. Follow the steps below to set up and execute the example.\n",
"This guide demonstrates how to use the **UniFace** library for face detection and visualization in this Jupyter Notebook. Follow the steps below to set up and execute the example.\n",
"\n",
"## 1. Install UniFace\n",
"Install the **UniFace** library using `pip`. The `-q` flag suppresses logs for a clean output."

View File

@@ -4,4 +4,4 @@ logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(message)s"
)
Logger = logging.getLogger("retinaface")
Logger = logging.getLogger("uniface")

View File

@@ -28,8 +28,6 @@ def draw_detections(image, detections, vis_threshold=0.6):
landmarks = landmarks[filtered]
scores = scores[filtered]
print(f"#faces: {len(scores)}")
# Draw bounding boxes, scores, and landmarks
for box, score, landmark in zip(boxes, scores, landmarks):
cv2.rectangle(image, box[:2], box[2:], (0, 0, 255), 2)