def main():
    fnet = SiameseFaceNet()
    fnet.vgg16_include_top = True

    model_dir_path = './models_1'
    image_dir_path = "./data/images"

    database = dict()



    database["aipengfei"] = [fnet.img_to_encoding(image_dir_path + "/aipengfei.png")]
    database["anyaru"] = [fnet.img_to_encoding(image_dir_path + "/anyaru.png")]
    database["baozhiqian"] = [fnet.img_to_encoding(image_dir_path + "/baozhiqian.png")]
    # 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")]

    fnet.fit(database=database, model_dir_path=model_dir_path)
def main():
    fnet = SiameseFaceNet()
    fnet.vgg16_include_top = True

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

    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")]

    fnet.fit(database=database, model_dir_path=model_dir_path)
Example #3
0

def createAug_1():
    rootdir = 'data/stu01'
    list = os.listdir(rootdir)  # 列出文件夹下所有的目录与文件
    count = 0
    for index in range(0, len(list)):
        #print (count)
        count = count + 1
        path = rootdir + "/" + list[index]
        listname = os.listdir(path)
        if len(listname) == 0:
            print(list[index])

        #os.makedirs( 'data/stu01/'+list[index])
        for i in range(0, len(listname)):
            #print(path + '/' + listname[i])
            imgpath = path + '/' + listname[0]
            img = cv2.imread(imgpath)  # 这是一个PIL图像
            #img =cv2.cvtColor( np.array(img), cv2.COLOR_BGR2RGB)
            #cv2.imwrite('data/stu01/' +list[index]+'/'+ listname[0], img)
            break


if __name__ == '__main__':
    #createAug_1()
    fnet = SiameseFaceNet()
    fnet.vgg16_include_top = True
    saveTrainPkl(fnet)
    main(fnet)
    createAug()