bow_utils.py 文件源码

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

项目:pybot 作者: spillai 项目源码 文件源码
def normalize_hist(hist, norm_method='global-l2'): 
    """
    Various normalization methods

    Refer to: 
    [1] Improving the Fisher Kernel for Large-Scale Image Classifcation, Perronnin et al
    http://www.robots.ox.ac.uk/~vgg/rg/papers/peronnin_etal_ECCV10.pdf

    [2] Segmentation Driven Object Detection with Fisher Vectors, Cinbis et al

    """

    # Component-wise mass normalization 
    if norm_method == 'component-wise-mass': 
        raise NotImplementedError('Component-wise-mass normalization_method not implemented')

    # Component-wise L2 normalization
    elif norm_method == 'component-wise-l2': 
        return hist / np.max(np.linalg.norm(hist, axis=1), 1e-12)

    # Global L2 normalization
    elif norm_method == 'global-l2': 
        return hist / (np.linalg.norm(hist) + 1e-12)

    # Square rooting / Power Normalization with alpha = 0.5
    elif norm_method == 'square-rooting': 
        # Power-normalization followed by L2 normalization as in [2]
        hist = np.sign(hist) * np.sqrt(np.fabs(hist))
        return hist / (np.linalg.norm(hist) + 1e-12)

    else: 
        raise NotImplementedError('Unknown normalization_method %s' % norm_method)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号