Package: facelib
facelibFace recognition python library(tensorflow, opencv).Usage (console)tryfacelib --helpto discover moreTrainfoo@bar:~$python3-mfacelibtraintrain_images/lotr
Currentpipeline:ssd_int8_cpu,mobilenetv2_fp32_cpu,densenet_fp32_cpu
Classifiernamed`lotr`succesfullytrainedandsaved.Folder structure:train_images/├───elijah_wood/├───├──0.jpg├───├──1.jpg├───liv_tyler/├───├──0.jpg├───├──1.jpg...Image NameImagetrain_images/ian_mckellen/0.jpgtrain_images/seanastin/0.jpgPredictfoo@bar:~$python3-mfacelibpredicttest_images/-clflotr-c-p
Currentpipeline:ssd_int8_cpu,mobilenetv2_fp32_cpu,densenet_fp32_cpu1.jpg
├───10facesdetected
├───['billy_boyd','sean_astin','viggo_mortensen','elijah_wood','liv_tyler','dominic_monaghan','sean_bean','ian_mckellen','peter_jackson','orlando_bloom']2.jpg
├───5facesdetected
├───['dominic_monaghan','billy_boyd','elijah_wood','sean_astin','peter_jackson']3.jpg
├───6facesdetected
├───['orlando_bloom','dominic_monaghan','john_rhys_davies','sean_astin','elijah_wood','billy_boyd']0.jpeg
├───5facesdetected
├───['dominic_monaghan','orlando_bloom','elijah_wood','liv_tyler','billy_boyd']Folder structure:test_images/├──0.jpeg├──1.jpg├──2.jpg├──3.jpgGenerated folders/files:test_images_facelib_cropped/├───elijah_wood/├───├──2_2.jpg├───├──3_1.jpg├───├──4_3.jpg├───liv_tyler/├───├──3_0.jpg├───├──4_1.jpg...Image NameImagetest_images_facelib_cropped/billy_boyd/0_1.jpgtest_images_facelib_cropped/liv_tyler/4_1.jpgtest_images_facelib_cropped/elijah_wood/3_1.jpgtest_images_facelib_plotted/1.jpgUsage (python)fromfacelibimportfacerecimportcv2# You can use face_detector, landmark_detector or feature_extractor individually using .predict method. e.g.(bboxes = facedetector.predict(img))face_detector=facerec.SSDFaceDetector()landmark_detector=facerec.LandmarkDetector()feature_extractor=facerec.FeatureExtractor()pipeline=facerec.Pipeline(face_detector,landmark_detector,feature_extractor)path_img='./path_to_some_image.jpg'img=cv2.imread(path_img)img=img[...,::-1]# cv2 returns bgr format but every method inside this package takes rgb formatbboxes,landmarks,features=pipeline.predict(img)# Note that values returned (bboxes and landmarks) are in fraction.[0,1]InstallationPip installationpip3installfacelibTFLite runtime installationTo use facelib.facerec package use the following bash command to install tflite-runtime pip package.python3-mfacelib--install-tfliteor you can install fromtensorflow.orgDev packageTensorflow is required for facelib.dev package. If you wish you can download facelib with tensorflow using the following command.pip3installfacelib[dev]InfoDatasetFeature extraction models are trained using insightfacesMS1M-Arcface.Landmark Detection models are trained usingVggFace2.ContentsImage AugmentationRandom augmentation for landmark detectionLayersDisturbLabelFace AlignmentInsightfaceGoldenRatioCustom ImplementationsTFRecordsWiderface to TFRecords converterVggFace2 to TFRecords converterCOFW to TFRecords converterLoss FunctionsFeature ExtractionArcFaceCombinedMarginSphereFace(A-Softmax)CenterCosFaceLandmark DetectionEuclideanDistance(with different norms)Pretrained ModelsFace DetectionSSDMTCNNFace Feature ExtractionMobileFaceNetSqueezeNetMobileNetMobileNetV2DenseNetNasNetMobileScriptsFeature extraction model trainingLandmark detection model trainingChokepoint test on pipelineFacial Landmark DetectionSqueezeNetMobileNetMobileNetV2DenseNetReferencesWiderFaceYang, Shuo, Ping Luo, Chen Change Loy, and Xiaoou Tang. “WIDER FACE: A Face Detection Benchmark.” ArXiv:1511.06523 [Cs], November 20, 2015.https://arxiv.org/abs/1511.06523ArcFaceDeng, Jiankang, Jia Guo, Niannan Xue, and Stefanos Zafeiriou. “ArcFace: Additive Angular Margin Loss for Deep Face Recognition.” ArXiv:1801.07698 [Cs], January 23, 2018.https://arxiv.org/abs/1801.07698MobileFaceNetChen, Sheng, Yang Liu, Xiang Gao, and Zhen Han. “MobileFaceNets: Efficient CNNs for Accurate Real-Time Face Verification on Mobile Devices.” CoRR abs/1804.07573 (2018).http://arxiv.org/abs/1804.07573VggFace2Cao, Qiong, Li Shen, Weidi Xie, Omkar M. Parkhi, and Andrew Zisserman. “VGGFace2: A Dataset for Recognising Faces across Pose and Age.” ArXiv:1710.08092 [Cs], October 23, 2017.http://arxiv.org/abs/1710.08092DenseNetG. Huang, Z. Liu, L. van der Maaten, and K. Q. Weinberger, “Densely Connected Convolutional Networks,” arXiv:1608.06993 [cs], Jan. 2018.http://arxiv.org/abs/1608.06993GoldenRatio (face alignment)M. Hassaballah, K. Murakami, and S. Ido, “Face detection evaluation: a new approach based on the golden ratio,” SIViP, vol. 7, no. 2, pp. 307–316, Mar. 2013.http://link.springer.com/10.1007/s11760-011-0239-3SqueezeNetF. N. Iandola, S. Han, M. W. Moskewicz, K. Ashraf, W. J. Dally, and K. Keutzer, “SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and <0.5MB model size,” arXiv:1602.07360 [cs], Feb. 2016.http://arxiv.org/abs/1602.07360MobileNetA. G. Howard et al., “MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications,” arXiv:1704.04861 [cs], Apr. 2017.http://arxiv.org/abs/1704.04861MobileNetV2M. Sandler, A. Howard, M. Zhu, A. Zhmoginov, and L.-C. Chen, “MobileNetV2: Inverted Residuals and Linear Bottlenecks,” arXiv:1801.04381 [cs], Jan. 2018.http://arxiv.org/abs/1801.04381CosFaceH. Wang et al., “CosFace: Large Margin Cosine Loss for Deep Face Recognition,” arXiv:1801.09414 [cs], Jan. 2018.http://arxiv.org/abs/1801.09414SphereFaceW. Liu, Y. Wen, Z. Yu, M. Li, B. Raj, and L. Song, “SphereFace: Deep Hypersphere Embedding for Face Recognition,” arXiv:1704.08063 [cs], Apr. 2017.http://arxiv.org/abs/1704.08063Bottleneck LayerK. He, X. Zhang, S. Ren, and J. Sun, “Deep Residual Learning for Image Recognition,” arXiv:1512.03385 [cs], Dec. 2015.http://arxiv.org/abs/1512.03385MS-Celeb-1MY. Guo, L. Zhang, Y. Hu, X. He, and J. Gao, “MS-Celeb-1M: A Dataset and Benchmark for Large-Scale Face Recognition,” arXiv:1607.08221 [cs], Jul. 2016.http://arxiv.org/abs/1607.08221DisturbLabelarXiv:1605.00055 [cs.CV]Single Shot Detector[1]W. Liu et al., “SSD: Single Shot MultiBox Detector,” arXiv:1512.02325 [cs], Dec. 2016.https://arxiv.org/abs/1512.02325LinksInsightfacehttps://github.com/deepinsight/insightfaceTensorflowhttps://github.com/tensorflow/tensorflowTensorflow-Addonshttps://github.com/tensorflow/addonsInsightface-DatasetZoohttps://github.com/deepinsight/insightface/wiki/Dataset-ZooTensorflow-ModelZoohttps://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.mdCascade Datahttps://github.com/opencv/opencv/tree/master/dataTFLite Pythonhttps://www.tensorflow.org/lite/guide/python