if __name__ == '__main__':
    data_path = '../dataset/'
    base_dir = '../dataset/WIDER_train/'
    filename = '../dataset/wider_face_train.txt'
    min_face_size = 20
    scale_factor = 0.79
    thresh = 0.6
    # 获取人脸的box图片数据
    print('开始生成bbox图像数据')
    crop_24_box_image(data_path, filename, min_face_size, scale_factor, thresh)
    # 获取人脸关键点的数据
    print('开始生成landmark图像数据')
    # 获取lfw negbox,关键点
    lfw_neg_path = os.path.join(data_path, 'trainImageList.txt')
    data_list = get_landmark_from_lfw_neg(lfw_neg_path, data_path)
    # 获取celeba,关键点
    # celeba_data_list = get_landmark_from_celeba(data_path)
    # data_list.extend(celeba_data_list)
    crop_landmark_image(data_path, data_list, 24, argument=True)
    # 合并数据列表
    print('开始合成数据列表')
    combine_data_list(os.path.join(data_path, '24'))
    # 合并图像数据
    print('开始合成图像文件')
    convert_data(os.path.join(data_path, '24'), os.path.join(data_path, '24', 'all_data'))
    # 删除旧数据
    print('开始删除就得图像文件')
    delete_old_img(data_path, 24)
Esempio n. 2
0
        chars = image.split('.')[0].split('_')[1]
        for c in chars:
            keys = label_dict.keys()
            if c not in keys:
                label_dict[c] = len(label_dict) + 1
        labels = [label_dict.get(c) for c in chars]

        label = ''
        for l in labels:
            label += '%s,' % l
        label = label[:-1]
        if i % 20 == 0:
            f_test.write("%s %s\n" % (image_path.replace('\\', '/'), label))
        else:
            f_train.write("%s %s\n" % (image_path.replace('\\', '/'), label))

    f_label.write("%s\n" % str(label_dict).replace("'", '"'))
    f_train.close()
    f_test.close()
    f_label.close()

    shuffle_data(train_list_path)
    print('create data list done!')


if __name__ == '__main__':
    create('dataset/images', config.train_list, config.test_list,
           config.dict_path)
    convert_data(config.train_list, config.train_prefix)
    convert_data(config.test_list, config.test_prefix)