Key takeaways
- Face biometrics compare a stored embedding template with a new capture against a threshold.
- Infrared hardware lets Face ID and Windows Hello work in the dark.
- InsightFace is more accurate than face_recognition, but its pretrained weights are non-commercial.
- Margin losses such as ArcFace beat plain softmax for recognising unseen faces.
- Detection finds faces, while recognition identifies people and carries heavier privacy duties.
Face recognition systems detect a face, convert it into an embedding and compare it with stored templates, with quality depending on detectors, training losses, cameras and lighting. I built FaceVision, which runs face detection, recognition and liveness in the browser with ONNX Runtime Web and stores only embeddings in PostgreSQL, so this page covers how face biometrics work, recognition in the dark, a Python tutorial, InsightFace versus face_recognition, detectors, Hikvision, loss functions, training time and phone use.
How does face recognition biometrics work?
Enrolment captures your face and converts it into a template, usually an embedding vector, stored securely. At verification, a new image is converted the same way and compared with the template; if similarity exceeds a threshold, access is granted.
The threshold balances false accepts, where the wrong person gets in, against false rejects, where you are refused. Liveness detection checks that a real person is present rather than a photo or mask. Secure systems store templates in protected hardware or encrypted databases and never keep raw images unnecessarily. FaceVision follows this principle, storing embeddings in PostgreSQL rather than photos. Even templates deserve strong protection, since biometrics cannot be changed like passwords. Periodic re-enrolment helps as appearance changes.
How does face recognition work in the dark?
Systems with infrared hardware, such as iPhone Face ID and Windows Hello cameras, work in darkness because they illuminate your face with invisible infrared light and capture infrared images or depth maps.
Phones relying on the normal front camera struggle in low light, so some brighten the screen to light your face, with mixed results. Infrared imaging also resists some spoofing, since photos look different in infrared. For custom systems, add infrared cameras or illumination for night use, such as attendance at entrances. Plan for glare and backlighting during the day as well. Test in the lighting conditions where the system will actually run, since accuracy can drop sharply in poor light.
What does a face recognition tutorial in Python cover?
A typical tutorial captures images with OpenCV, detects faces, aligns them, computes embeddings with a pretrained model, stores embeddings for known people, and identifies new faces by comparing embeddings with cosine similarity and a threshold.
Also asked as: face recognition tutorial python
Beginners often start with the face_recognition library for a few lines of code, then move to InsightFace models for higher accuracy. A FastAPI service can expose enrolment and matching endpoints, storing embeddings in PostgreSQL, the same stack FaceVision uses. Keep code modular so you can swap models later. Add liveness checks, consent prompts and tests across lighting and demographics. Evaluate false accept and false reject rates on a validation set before using the system for anything important.
InsightFace vs face_recognition: which should you use?
face_recognition, built on dlib, is easy to start with and runs on CPUs, but its models are older. InsightFace provides state-of-the-art detection and ArcFace recognition models with better accuracy on hard cases, and GPU or ONNX acceleration.
An important difference is licensing: InsightFace's pretrained model weights are released for non-commercial research use, so commercial products need licensed models or ones trained on permissively licensed data. face_recognition's dlib models are more permissive but less accurate on difficult images. For learning, either works; for production, weigh accuracy, licence, speed and maintenance. Test both on your own images, including varied angles and lighting.
What are good pre-trained models for face or head detection?
Strong face detectors include RetinaFace and SCRFD from the InsightFace project, OpenCV's lightweight YuNet, Google's MediaPipe face detector and YOLO models fine-tuned for faces. For head detection in crowds, models trained on datasets such as CrowdHuman work well.
Also asked as: can anyone recommend me a very good pre-trained model for face or head detection
Choose by speed, accuracy and hardware: YuNet and MediaPipe run fast on CPUs and phones, SCRFD offers excellent accuracy-speed trade-offs, and RetinaFace provides landmarks useful for alignment. Head detectors help when faces are turned away, such as counting people in queues. Check licences before commercial use, and evaluate on images resembling your deployment, since detectors trained on frontal photos may miss small or angled faces.
What is the difference between Hikvision face detection and face recognition?
In Hikvision and similar CCTV systems, face detection notices that a face is present and captures a snapshot or triggers an event. Face recognition goes further, comparing captured faces against a stored face library to identify specific people.
Also asked as: hikvision face detection vs face recognition
Detection works on many cameras, while recognition usually needs compatible cameras or recorders with face analytics and configured face libraries. Recognition raises much greater privacy and legal obligations, including consent, purpose limitation and data retention rules under laws such as India's data protection law. Use detection for counting or alerts where identity is unnecessary, and recognition only with clear justification, notices and secure handling of biometric data. Review vendor firmware updates regularly for security fixes.
Why is plain softmax loss not preferred for face recognition?
Plain softmax loss trains features that separate known identities but does not make same-person features tightly clustered or different people far apart. Face recognition must compare unseen people, so it needs highly discriminative embeddings.
Also asked as: why is a general/original softmax loss not preferred in fr (face recognition
Margin-based losses, such as SphereFace, CosFace and ArcFace, normalise features and class weights and add an angular or cosine margin, forcing embeddings of the same identity closer and different identities further apart. This greatly improves verification on new faces, which plain softmax handles poorly. ArcFace's additive angular margin became the standard for training modern face recognition models, including many used in production systems and open-source toolkits. Understanding this loss helps when choosing thresholds.
How long does it take to train a face recognition neural network?
Roughly, training a strong model such as ArcFace with a ResNet backbone on millions of face images takes about a day or more on several modern GPUs, while fine-tuning a pretrained model on a small dataset takes minutes to hours.
Also asked as: how long it takes to train face recognition deep neural network? (rough estimation
Time depends on dataset size, backbone depth, image resolution, number of GPUs and training epochs. Large public face datasets have licensing and privacy issues, so most teams use pretrained models rather than training from scratch. Fine-tuning helps adapt to specific conditions, such as infrared cameras or particular demographics. Track verification accuracy on a held-out set throughout training. Budget extra time for data cleaning, evaluation and threshold tuning, which often take longer than training itself.
Should you use face recognition on your phone?
Yes, if your phone uses secure face unlock, such as iPhone Face ID or Class 3 Android face unlock, it offers strong convenience with good security. Camera-only face unlock is fine for convenience but weaker than fingerprint or a strong PIN.
Also asked as: should i use face recognition on my phone
Consider your situation: if someone could hold the phone to your face while you are unaware, enable eyes-open or attention requirements, and know how to temporarily disable biometrics quickly. Use a strong passcode as the backup, since it protects your device when biometrics are bypassed. For sensitive apps, such as banking, check which biometric methods they accept. Face data on phones stays in secure hardware, not on company servers.
How does face recognition work on Samsung phones?
Samsung Galaxy face recognition uses the front camera to capture a 2D image of your face and compares it with your registered face data stored securely on the phone. It is designed for convenience rather than high security.
Samsung notes that face recognition is less secure than a PIN, pattern, password or fingerprint, and it is not accepted for Samsung Pass or payments. Settings include an option requiring open eyes and a faster recognition option that slightly reduces security. Registering an alternative look helps with glasses or hairstyles. For stronger protection, use the fingerprint sensor for sensitive tasks and keep face recognition for quick unlocking.
Sources
- Deng et al., ArcFace: Additive Angular Margin Loss for Deep Face Recognitionarxiv.org
- InsightFace, repositorygithub.com
- face_recognition, repositorygithub.com
- Wang et al., CosFace: Large Margin Cosine Loss for Deep Face Recognitionarxiv.org
- Guo et al., Sample and Computation Redistribution for Efficient Face Detection (SCRFD)arxiv.org
- OpenCV, FaceDetectorYN (YuNet)docs.opencv.org




