def main():
    model_dir_path = './demo/models'
    image_dir_path = "./demo/data/images"

    fnet = FaceNet()
    fnet.load_model(model_dir_path)

    database = {}
    #     database["danielle"] = fnet.img_to_encoding(image_dir_path + "/danielle.png")
    # fnet.img_to_encoding(image_dir_path + "/lyz.jpg")
    database["ybg"] = fnet.img_to_encoding(image_dir_path + "/ybg.jpg")
    database["tian"] = fnet.img_to_encoding(image_dir_path + "/tian.jpg")

    # verifies whether a particular camera image is a person in the image database
    dist, is_valid = fnet.verify(image_dir_path + "/camera_6.jpg", "ybg",
                                 database)
    print('camera_6.jpg is' + (' ' if is_valid else ' not ') + 'ybg')

    # whether a particular camera image is which person in the image database (or not at all)
    dist, identity = fnet.who_is_it(image_dir_path + "/camera_6.jpg", database)
    if identity is None:
        print('camera_6.jpg is not found in database')
    else:
        print('camera_6.jpg is ' + str(identity))
def main():

    if len(sys.argv) < 3:

        print("usage: face_recognition_launcher <path> <id>")
        return 1

    image_path = sys.argv[1]
    person_id = sys.argv[2]

    model_dir_path = './demo/models'
    image_dir_path = "./demo/data/images/"

    fnet = FaceNet()
    fnet.load_model(model_dir_path)

    database = {}

    for root, dirs, files in os.walk(image_dir_path):
        for file in files:
            # print(image_dir_path + file)
            database[file.split('.')[0]] = fnet.img_to_encoding(
                image_dir_path + file)

    dist, is_valid = fnet.verify(image_path, person_id, database)

    is_found = False
    identity = None

    if is_valid:
        is_found = True
    else:
        dist, identity = fnet.who_is_it(image_path, database)

    print(str(is_found) + " : " + identity)
    return is_found, identity
Beispiel #3
0
def main():
    model_dir_path = './models_1'
    image_dir_path = "./data/images"

    fnet = FaceNet()
    fnet.load_model(model_dir_path)

    database = dict()
    database["danielle"] = fnet.img_to_encoding(image_dir_path + "/danielle.png")
    database["younes"] = fnet.img_to_encoding(image_dir_path + "/younes.jpg")
    database["tian"] = fnet.img_to_encoding(image_dir_path + "/tian.jpg")
    database["andrew"] = fnet.img_to_encoding(image_dir_path + "/andrew.jpg")
    database["kian"] = fnet.img_to_encoding(image_dir_path + "/kian.jpg")
    database["dan"] = fnet.img_to_encoding(image_dir_path + "/dan.jpg")
    database["sebastiano"] = fnet.img_to_encoding(image_dir_path + "/sebastiano.jpg")
    database["bertrand"] = fnet.img_to_encoding(image_dir_path + "/bertrand.jpg")
    database["kevin"] = fnet.img_to_encoding(image_dir_path + "/kevin.jpg")
    database["felix"] = fnet.img_to_encoding(image_dir_path + "/felix.jpg")
    database["benoit"] = fnet.img_to_encoding(image_dir_path + "/benoit.jpg")
    database["arnaud"] = fnet.img_to_encoding(image_dir_path + "/arnaud.jpg")

    dist, is_valid = fnet.verify(image_dir_path + "/camera_0.jpg", "younes", database)
    print('camera_0.jpg is' + (' ' if is_valid else ' not ') + 'yournes')
    dist, is_valid = fnet.verify(image_dir_path + "/camera_2.jpg", "kian", database)
    print('camera_0.jpg is' + (' ' if is_valid else ' not ') + 'yournes')
    dist, identity = fnet.who_is_it(image_dir_path + "/camera_0.jpg", database)
    if identity is None:
        print('camera_0.jpg is not found in database')
    else:
        print('camera_0.jpg is ' + str(identity))
Beispiel #4
0
def main():
    model_dir_path = './models'
    image_dir_path = "./data/images"

    fnet = FaceNet()
    fnet.load_model(model_dir_path)

    database = dict()
    database["danielle"] = fnet.img_to_encoding(image_dir_path + "/danielle.png")
    database["younes"] = fnet.img_to_encoding(image_dir_path + "/younes.jpg")
    database["tian"] = fnet.img_to_encoding(image_dir_path + "/tian.jpg")
    database["andrew"] = fnet.img_to_encoding(image_dir_path + "/andrew.jpg")
    database["kian"] = fnet.img_to_encoding(image_dir_path + "/kian.jpg")
    database["dan"] = fnet.img_to_encoding(image_dir_path + "/dan.jpg")
    database["sebastiano"] = fnet.img_to_encoding(image_dir_path + "/sebastiano.jpg")
    database["bertrand"] = fnet.img_to_encoding(image_dir_path + "/bertrand.jpg")
    database["kevin"] = fnet.img_to_encoding(image_dir_path + "/kevin.jpg")
    database["felix"] = fnet.img_to_encoding(image_dir_path + "/felix.jpg")
    database["benoit"] = fnet.img_to_encoding(image_dir_path + "/benoit.jpg")
    database["arnaud"] = fnet.img_to_encoding(image_dir_path + "/arnaud.jpg")

    dist, is_valid = fnet.verify(image_dir_path + "/camera_0.jpg", "younes", database)
    print('camera_0.jpg is' + (' ' if is_valid else ' not ') + 'yournes')
    dist, is_valid = fnet.verify(image_dir_path + "/camera_2.jpg", "kian", database)
    print('camera_0.jpg is' + (' ' if is_valid else ' not ') + 'yournes')
    dist, identity = fnet.who_is_it(image_dir_path + "/camera_0.jpg", database)
    if identity is None:
        print('camera_0.jpg is not found in database')
    else:
        print('camera_0.jpg is ' + str(identity))
Beispiel #5
0
def load_obj(name):
    with open(name + '.pkl', 'rb') as f:
        return pickle.load(f)


#iniciate id counter
id = 0

# names related to ids: example ==> Marcelo: id=1,  etc
model_dir_path = './models/fnet_w.h5'
image_dir_path = "./images"

names = os.listdir(image_dir_path)

fnet = FaceNet()
fnet.load_model(model_dir_path)

database = load_obj('database')

face_detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor('shape_predictor_68_face_landmarks.dat')
fa = FaceAligner(predictor, desiredFaceWidth=96)

cam = cv2.VideoCapture(1)
cam.set(3, 640)  # set video width
cam.set(4, 480)  # set video height

# Frontal faces pattern

check_dir = "./check"
Beispiel #6
0
        pickle.dump(obj, f, pickle.HIGHEST_PROTOCOL)


def load_obj(name):
    with open(name + '.pkl', 'rb') as f:
        return pickle.load(f)


cam = cv2.VideoCapture(1)
cam.set(3, 640)  # set video width
cam.set(4, 480)  # set video height

model_dir_path = './models/fnet_w.h5'
image_dir_path = "./images"

fnet = FaceNet()
fnet.load_model(model_dir_path)

database = load_obj('database')

print(database)
clr = int(input("Would you like to clear the database?"))
if clr:
    database = dict()
    print("Database Cleared!")
else:
    pass

# Frontal faces pattern
#face_detector = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml')
face_detector = dlib.get_frontal_face_detector()