def preprocess_label(label):
"""
load label image, keep a single channel (all three should be the same)
:param label:
:return:
"""
# TODO: Populate with actual logic and move away from here into a dedicated class (like ImageDataGenerator)
# target = 'pillow' if mode == 'pillow' else 'numpy'
# # lbl = resize(lbl, target_h, target_w, mode=mode, target_type='numpy', keep_aspect_ratio=keep_aspect_ratio)
# if mode == 'pillow':
# # lbl = np.expand_dims(lbl[:, :, 0], axis=2)
# assert np.all(lbl[:, :, 0] == lbl[:, :, 1]) and np.all(lbl[:, :, 0] == lbl[:, :, 2])
# lbl = lbl[:, :, 0].astype(np.uint8)
# array2d = mapper[lbl]
# onehot_lbl = to_categorical(array2d, num_classes=nc)
# return onehot_lbl
return label
评论列表
文章目录