preprocess.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:plda 作者: RaviSoji 项目源码 文件源码
def preprocess_faces(images, n_components='default', resize_shape='default'):
    """ Notes: Images are all square, but not the same size. We resize all the
                images to be the same sized square, thereby preserving the
                aspect ratios.
    """
    for img in images:
        assert img.shape[0] == img.shape[1]

    if resize_shape == 'default':
        resize_shape = get_smallest_shape(images)

    preprocessed_images = []
    for img in images:
        prepped_img = imresize(img, resize_shape).astype(float)
        prepped_img = prepped_img.flatten()
        preprocessed_images.append(prepped_img)
    preprocessed = get_principal_components(preprocessed_images, n_components)

    return preprocessed
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号