Face Recognition sample code in Python

import face_recognition
import PIL.Image
import PIL.ImageDraw
from pathlib import Path

for filename in Path("./").glob("*.jpg"):

    # Load the jpg files into numpy arrays
    image = face_recognition.load_image_file(filename)

    # Generate the face encodings
    face_encodings = face_recognition.face_encodings(image)

    if len(face_encodings) == 0:
        # No faces found in the image.
        print("No faces were found in {}.".format(filename))

        # Grab the first face encoding
        first_face_encoding = face_encodings[0]

        # Print the results
        print("Face encoding for {}\n".format(filename),first_face_encoding)
        # Find all facial features in all the faces in the image
        face_landmarks_list = face_recognition.face_landmarks(image)

        number_of_faces = len(face_landmarks_list)
        print("I found {} face(s) in this photograph.".format(number_of_faces))

        # Load the image into a Python Image Library object so that we can draw on top of it and display it
        pil_image = PIL.Image.fromarray(image)

        # Create a PIL drawing object to be able to draw lines later
        draw = PIL.ImageDraw.Draw(pil_image)

        # Loop over each face
        for face_landmarks in face_landmarks_list:

            # Loop over each facial feature (eye, nose, mouth, lips, etc)
            for name, list_of_points in face_landmarks.items():
                # Print the location of each facial feature in this image
                print("The {} in this face has the following points: {}".format(name, list_of_points))

                # Let's trace out each facial feature in the image with a line!
                draw.line(list_of_points, fill="red", width=2)

Source: Wikipedia
閱讀全文 Face Recognition sample code in Python

Deep Learning Framrworks (深度學習軟體框架)

Deep Learning Frameworks (深度學習軟體框架)

目前以TensorFlow, Theano, Keras, Torch, Caffe為主。搭配硬體或GPU加速的架構 (像是NVIDIA CUDA等)。深度學習可以開發的領域目前集中在電腦視覺(從影像或視訊擷取資訊、臉部辨別、內容分析診斷等等)。


Image Source: NVIDIA
 閱讀全文 Deep Learning Framrworks (深度學習軟體框架)