Computer Vision News - April 2022

13 Facial Recognition with Open CV2 Step 1.4: Cut Faces and resize faces for (x, y, w, h) in faces_coord: cv2.rectangle(frame, (x, y), (x + w, y + h), (150, 150, 0), 8) plt_show(frame) def cut_faces(image, faces_coord): faces = [] for (x, y, w, h) in faces_coord: w_rm = int(0.2 * w / 2) faces.append(image[y: y + h, x + w_rm: x + w - w_rm]) return faces Cut_Face = cut_faces(frame, faces_coord) plt_show(Cut_Face[0]) Define a function to resize the face back to 224x224 resolution def resize(images, size=(224, 224)): images_norm = [] for image in images: if image.shape < size: image_norm = cv2.resize(image, size, interpolation = cv2.INTER_AREA) else : image_norm = cv2.resize(image, size, interpolation = cv2.INTER_CUBIC) images_norm.append(image_norm) return images_norm resize_faces = resize(Cut_Face) plt_show(resize_faces[0]) Step 1.5: Standardize the image for fitting Neural Net Model Normalizing image inputs: Data normalization is an important step, which ensures that each input parameter (pixel, in this case) has a similar data distribution. This makes convergence faster while training the network. For image inputs we need the pixel numbers to be positive, so we might choose to scale the normalized data in the range [0,1] resize_face_stad = resize_faces[0]/255.0 plt.imshow((resize_faces[0]/255)) Pre-trained Model in TensorFlow Step 2.1 Install libraries VGGFace and VGGFace2 Models The VGGFace refers to a series of models developed for face recognition and demonstrated on benchmark computer vision datasets by members of the Visual Geometry Group (VGG) at the University of Oxford. For more information, please visit the github link: https://github.com/rcmalli/keras-vggface

RkJQdWJsaXNoZXIy NTc3NzU=