Ejemplo n.º 1
0
def create_face_embedding(model_path,dataset_path,out_emb_path,out_filename):
    # 建立npy文件
    files_list,names_list=file_processing.gen_files_labels(dataset_path,postfix=['*.jpg'])
    embeddings,label_list=get_face_embedding(model_path,files_list, names_list)
    print("label_list:{}".format(label_list))
    print("have {} label".format(len(label_list)))
    embeddings=np.asarray(embeddings)
    np.save(out_emb_path, embeddings)
    file_processing.write_list_data(out_filename, label_list, mode='w')
Ejemplo n.º 2
0
def save_id(train_id_path, train_id, val_id_path, val_id):
    if not os.path.exists(os.path.dirname(train_id_path)):
        os.makedirs(os.path.dirname(train_id_path))
    if not os.path.exists(os.path.dirname(val_id_path)):
        os.makedirs(os.path.dirname(val_id_path))
    # 保存图片id数据
    file_processing.write_list_data(train_id_path, train_id, mode="w")

    file_processing.write_list_data(val_id_path, val_id, mode="w")
    print("train num:{},save path:{}".format(len(train_id), train_id_path))
    print("val   num:{},save path:{}".format(len(val_id), val_id_path))
Ejemplo n.º 3
0
def create_face_embedding(model_path, dataset_path, out_emb_path,
                          out_filename):
    '''

    :param model_path: faceNet模型路径
    :param dataset_path: 人脸数据库路径,每一类单独一个文件夹
    :param out_emb_path: 输出embeddings的路径
    :param out_filename: 输出与embeddings一一对应的标签
    :return: None
    '''
    files_list, names_list = file_processing.gen_files_labels(
        dataset_path, postfix=['*.jpg', '*jpeg'])
    embeddings, label_list = get_face_embedding(model_path, files_list,
                                                names_list)
    print("label_list:{}".format(label_list))
    print("have {} label".format(len(label_list)))

    embeddings = np.asarray(embeddings)
    np.save(out_emb_path, embeddings)
    file_processing.write_list_data(out_filename, label_list, mode='w')