ref: Add comprehensive test suite and enhance model functionality

- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
This commit is contained in:
yakhyo
2025-11-15 21:09:37 +09:00
parent df673c4a3f
commit 2c78f39e5d
28 changed files with 2014 additions and 591 deletions

View File

@@ -1,18 +1,97 @@
### `download_model.py`
# Scripts
# Download all models
Collection of example scripts demonstrating UniFace functionality.
## Available Scripts
- `run_detection.py` - Face detection on images
- `run_age_gender.py` - Age and gender prediction
- `run_landmarks.py` - Facial landmark detection
- `run_recognition.py` - Face recognition and embeddings
- `run_face_search.py` - Face search and matching
- `run_video_detection.py` - Video processing with face detection
- `batch_process.py` - Batch processing of image folders
- `download_model.py` - Download and manage models
## Quick Start
```bash
python scripts/download_model.py
# Face detection
python scripts/run_detection.py --image assets/test.jpg
# Age and gender detection
python scripts/run_age_gender.py --image assets/test.jpg
# Webcam demo
python scripts/run_age_gender.py --webcam
# Batch processing
python scripts/batch_process.py --input images/ --output results/
```
# Download just RESNET18
## Import Examples
```bash
python scripts/download_model.py --model RESNET18
The scripts use direct class imports for better developer experience:
```python
# Face Detection
from uniface.detection import RetinaFace, SCRFD
detector = RetinaFace() # or SCRFD()
faces = detector.detect(image)
# Face Recognition
from uniface.recognition import ArcFace, MobileFace, SphereFace
recognizer = ArcFace() # or MobileFace(), SphereFace()
embedding = recognizer.get_embedding(image, landmarks)
# Age & Gender
from uniface.attribute import AgeGender
age_gender = AgeGender()
gender, age = age_gender.predict(image, bbox)
# Landmarks
from uniface.landmark import Landmark106
landmarker = Landmark106()
landmarks = landmarker.get_landmarks(image, bbox)
```
### `run_inference.py`
## Available Classes
**Detection:**
- `RetinaFace` - High accuracy face detection
- `SCRFD` - Fast face detection
**Recognition:**
- `ArcFace` - High accuracy face recognition
- `MobileFace` - Lightweight face recognition
- `SphereFace` - Alternative face recognition
**Attributes:**
- `AgeGender` - Age and gender prediction
**Landmarks:**
- `Landmark106` - 106-point facial landmarks
## Common Options
Most scripts support:
- `--help` - Show usage information
- `--verbose` - Enable detailed logging
- `--detector` - Choose detector (retinaface, scrfd)
- `--threshold` - Set confidence threshold
## Testing
Run basic functionality test:
```bash
python scripts/run_inference.py --image assets/test.jpg --model MNET_V2 --iterations 10
```
python scripts/run_detection.py --image assets/test.jpg
```
For comprehensive testing, see the main project tests:
```bash
pytest tests/
```