0
0
Computer Visionml~5 mins

Face recognition concept in Computer Vision

Choose your learning style9 modes available
Introduction
Face recognition helps computers find and identify people by looking at their faces, just like how we recognize friends and family.
Unlocking your phone using your face instead of a password.
Automatically tagging friends in photos on social media.
Checking who is at the door using a smart security camera.
Finding missing people by matching faces in public places.
Personalizing experiences in stores by recognizing returning customers.
Syntax
Computer Vision
face_recognizer = FaceRecognitionModel()
face_recognizer.train(training_images, labels)
predictions = face_recognizer.predict(test_images)
FaceRecognitionModel is a placeholder for any face recognition algorithm or library you use.
Training means teaching the model to know faces by showing labeled pictures.
Examples
Train the model with pictures of friends and their names, then find who is in new photos.
Computer Vision
face_recognizer = FaceRecognitionModel()
face_recognizer.train(images_of_friends, friend_names)
predictions = face_recognizer.predict(new_photos)
Use face recognition to identify employees from a live camera feed.
Computer Vision
face_recognizer = FaceRecognitionModel()
face_recognizer.train(employee_photos, employee_ids)
recognized = face_recognizer.predict(camera_feed)
Sample Model
This simple example uses points to represent faces and a KNN model to recognize who the new face belongs to.
Computer Vision
import numpy as np
from sklearn.neighbors import KNeighborsClassifier

# Sample face data: each face is a simple 2D point (for example only)
face_features = np.array([[1, 2], [2, 3], [3, 4], [10, 10], [11, 11], [12, 12]])
labels = ['Alice', 'Alice', 'Alice', 'Bob', 'Bob', 'Bob']

# Create and train a simple KNN model
model = KNeighborsClassifier(n_neighbors=1)
model.fit(face_features, labels)

# New face to recognize
new_face = np.array([[2, 2]])
prediction = model.predict(new_face)
print(f"Recognized person: {prediction[0]}")
OutputSuccess
Important Notes
Real face recognition uses complex features from images, not simple points.
Models need many face pictures to learn well and recognize accurately.
Lighting, angle, and expression can affect face recognition results.
Summary
Face recognition lets computers identify people by their faces.
It works by training a model with known face images and labels.
The model predicts who is in new images by comparing features.