nn/nn_utils.py
def decode_labels(label, label_num=2):
    """
    Decode label prediction map into rgb color map
    :param label: label prediction map
    :param label_num: #distinct classes in ground truth
    :return:
    """
    n, h, w, c = label.shape
    outputs = np.zeros((n, h, w, 3), dtype=np.uint8)
    color_list = ersa_utils.get_color_list()
    label_colors = {}
    for i in range(label_num):
        label_colors[i] = color_list[i]
    label_colors[0] = (255, 255, 255)
    for i in range(n):
        pixels = np.zeros((h, w, 3), dtype=np.uint8)
        for j in range(h):
            for k in range(w):
                pixels[j, k] = label_colors[np.int(label[i, j, k, 0])]
        outputs[i] = pixels
    return outputs

    Decode label prediction map into rgb color map
    :param label: label prediction map
    :param label_num: #distinct classes in ground truth
    :return:
    
Decode label prediction map into rgb color map
Decode label prediction map into rgb color map
def decode_labels(label, label_num=2):
    n, h, w, c = label.shape
    outputs = np.zeros((n, h, w, 3), dtype=np.uint8)
    color_list = ersa_utils.get_color_list()
    label_colors = {}
    for i in range(label_num):
        label_colors[i] = color_list[i]
    label_colors[0] = (255, 255, 255)
    for i in range(n):
        pixels = np.zeros((h, w, 3), dtype=np.uint8)
        for j in range(h):
            for k in range(w):
                pixels[j, k] = label_colors[np.int(label[i, j, k, 0])]
        outputs[i] = pixels
    return outputs
def decode_labels ( label , label_num = 2 ) : n , h , w , c = label . shape outputs = np . zeros ( ( n , h , w , 3 ) , dtype = np . uint8 ) color_list = ersa_utils . get_color_list ( ) label_colors = { } for i in range ( label_num ) : label_colors [ i ] = color_list [ i ] label_colors [ 0 ] = ( 255 , 255 , 255 ) for i in range ( n ) : pixels = np . zeros ( ( h , w , 3 ) , dtype = np . uint8 ) for j in range ( h ) : for k in range ( w ) : pixels [ j , k ] = label_colors [ np . int ( label [ i , j , k , 0 ] ) ] outputs [ i ] = pixels return outputs
Decode label prediction map into rgb color map
Decode label prediction map into rgb color map
"""
    Decode label prediction map into rgb color map
    :param label: label prediction map
    :param label_num: #distinct classes in ground truth
    :return:
    """
None
label
label prediction map
label prediction map
label_num
distinct classes in ground truth
distinct classes in ground truth