inference.py 文件源码

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

项目:DeepNet 作者: hok205 项目源码 文件源码
def prediction_to_image(prediction, reshape=False):
    """ Converts a prediction map to the RGB image

    Args:
        prediction (array): the input map to convert
        reshape (bool, optional): True if reshape the input from Caffe format
                                  to numpy standard 2D array

    Returns:
        array: RGB-encoded array
    """
    if reshape:
        prediction = np.swapaxes(np.swapaxes(prediction, 0, 2), 0, 1)
    image = np.zeros(prediction.shape[:2] + (3,), dtype='uint8')
    for x in xrange(prediction.shape[0]):
        for y in xrange(prediction.shape[1]):
            image[x,y] = label_to_pixel(prediction[x,y])
    return image


# In[6]:

# Simple sliding window function
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号