A face indexing, storage, and similarity search system built on InsightFace embeddings and Annoy approximate nearest neighbors.
FaceDB extracts facial embeddings from image collections and enables efficient similarity searches. The system consists of two main components:
- Indexer - Processes images to detect faces, extract embeddings, and build a searchable index
- Searcher - Queries the index to find similar faces across your collection
# Clone the repository
git clone https://github.com/kennethwolters/facedb.git
cd facedb
# Create a virtual environment
python -m venv env
source env/bin/activate # Linux/macOS
# or
# env\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txtProcess a directory of images and build a searchable index:
python facedb.py /path/to/images --annoy index.ann --visualize vis_dirOptions:
--gpu- Enable GPU acceleration--det-size- Detection size (default: 640)--n-trees- Number of trees for Annoy index (default: 10)--distance- Distance metric (angular, euclidean, manhattan, hamming, dot)
Find faces similar to a specific face in your collection:
python search.py /path/to/image.jpg 1 --annoy index.ann --top 10 --visualize results.jpgArguments:
- First argument: Path to the query image
- Second argument: Face number in the image (1-based indexing)
--annoy- Path to the Annoy index--top- Number of similar faces to return--visualize- Path to save visualization image
- InsightFace for face detection and recognition
- Annoy for efficient similarity search