Pytorch0.4.1 codes for counting the number of unique faces under a directory containing images.
-
This repo is heavily borrowed from Insightface_Pytorch
-
This code also save the identity embeddings of the unique faces found as an
.npzfile, where the keys areembeddings: the identity embeddings, PyTorch tensor of shape (num_embeddings, embed_dim) names: the names of the embeddings, array of shape (num_embeddings + 1,) where the first being "Unknown" emb_counts: number of occurances of each embeddings, array of shape (num_embeddings,) -
Pretrained weights. (Note: I used IR-SE50) For InsightFace IR-SE50 @ Onedrive For RetinaFace RetinaFace-R50
-
clone this repo
git clone https://github.com/yongxinw/face_counting.git -
install requirements by (requires python 3.6)
pip install -r requirements.txt -
set environmental variables
export LD_LIBRARY_PATH=<path_to_cuda_installation>/lib64:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=<path_to_cuda_installation>:$LD_LIBRARY_PATH -
download pretrained weights by clicking the links from section 1
- go to the RetinaFace directory, and compile RetinaFace
cd <path_to_this_repo>/RetinaFace make - run RetinaFace detection
python test_folder.py \ --image_root <directory containing images> \ --res_root <directory to save detection visualizations> \ --model_path <path to the pretrained model>
- run the following command to count the number of faces under a directory
cd <path_to_this_repo> python count_faces.py \ --result_root <directory to save the .npz file> \ --retinaface <path to .txt file containing the RetinaFace detection> \ --image_root <directory of the images> \ --model_path <directory containing the insightface pretrained model> \ --verbose
- This repo is heavily borrowed from Insightface_Pytorch
- See also deepinsight/insightface