How ao-lee/vgg-face-fine-tune works
Project Type and Purpose
• This is a standalone machine-learning pipeline for face detection, alignment, feature-extraction (via VGGFace), verification, and fine-tuning on custom datasets.
• Key features:
• Face detection & alignment (UtilsAlign)
• Feature extraction & triplet-loss training (vggface.py, train.py)
• Verification & threshold generation (TestCases)
• Custom dataset support via data loaders (UtilsData)
File Structure
Top-level files:
• cfg.py – global configuration (model paths, hyperparameters)
• data.py, utils.py – general utilities
• vggface.py – VGG-16–based model definition & embedding extractor
• train.py – training script (triplet loss)
• TestCases/ – end-to-end integration tests for detection, alignment, verification
• UtilsAlign/ – submodule for face detection, alignment, landmarking
– base/ (cascade nets)
– bbox.py, landmarks.py, database.py, common.py
• UtilsData/ – data pipeline submodule
– dataloader.py, dataset.py, sampler.py
README for Insights
• Confirms use of VGG-16 pre-trained on 2,622 identities, fine-tuned with triplet loss.
• Outlines workflows: detection→alignment, verification on general/single pairs, training.
• External dependencies: TensorFlow, Keras, tqdm.
Main Components & Interactions
A. Dataset Sources
• Raw Image Repositories (e.g., LFW, ARFace, CAS-PEAL)
• Aligned Image Store (output of alignment pipeline)
B. Preprocessing Pipeline (UtilsAlign)
• Face Detector (base/detect.py + det1/2/3.npy cascades)
• Landmark Predictor (landmarks.py)
• Alignment Database Manager (database.py)
C. Data Loading Layer (UtilsData)
• Dataset Classes (dataset.py)
• Samplers (sampler.py)
• Dataloader (dataloader.py)
D. Core Model & Training
• VGGFace Model Definition (vggface.py)
• Triplet Loss Module (in train.py)
• Configuration (cfg.py)
• Training Script (train.py)
E. Verification & Threshold Generation
• Embedding Extraction (reuse vggface.py)
• Pairwise Distance Computation
• Threshold Finder (test_best_threshold_generation.py)
• Verification Tests (TestCases/test_verification*.py)
F. External Components
• Pre-trained VGGFace weights (download link managed via cfg.py)
• Keras/TensorFlow Runtime
• File System & Storage
Relationships and Data Flow
• Configuration flows into Preprocessing, Data Loader, and Training scripts
• External weight download feeds into Core Model
Architectural Patterns & Principles
• Modular separation:
• UtilsAlign for all preprocessing
• UtilsData for data handling
• vggface.py + train.py for model logic
• Single-responsibility: each module handles one stage
• Test-driven validation: TestCases cover alignment, detection, verification
• Pluggable datasets: reader classes in data.py + LFWReader usage in train.py
Technologies & Frameworks
• Python 3 (Anaconda)
• TensorFlow + Keras
• NumPy (.npy detector files)
• tqdm for progress reporting
• Standard file I/O for dataset management