def q1_c(): model = load_facenet() files = os.listdir("saved_faces") data = [] paths = [] for path in files: image = cv.imread("saved_faces/" + path) v = img_to_encoding(image, model) data.append(v) paths.append(path) with open("saved_data.pickle", "wb") as handle: pickle.dump([data, paths], handle, protocol=pickle.HIGHEST_PROTOCOL)
def get_embedding_path(): """ q1(c) """ model = load_facenet() files = os.listdir("saved_faces") embedding, paths = [], [] for path in files: image = cv.imread("saved_faces/" + path) encode = img_to_encoding(image, model) embedding.append(encode) paths.append(path) return embedding, paths
def loading_input(): """ q1(h) helper function, return the (embedding, paths) of the input file """ model = load_facenet() input_img = os.listdir("input_faces") embedding, paths = [], [] for path in input_img: image = cv.imread("input_faces/" + path) image = cv.resize(image, (96, 96)) encode = img_to_encoding(image, model) embedding.append(encode) paths.append(path) return embedding, paths