def preprocess_labels(label, number_slices):
"""Preprocess the labels to adapt them to the loss computation requirements
Args:
Label corresponding to the input image (W,H) numpy array
Returns:
Label ready to compute the loss (1,W,H,1)
"""
labels = [[] for i in range(np.array(label).shape[0])]
for j in range(np.array(label).shape[0]):
if type(label) is not np.ndarray:
for i in range(number_slices):
labels[j].append(np.array(Image.open(label[0][i]), dtype=np.uint8))
label = np.array(labels[0])
label = label.transpose((1,2,0))
max_mask = np.max(label) * 0.5
label = np.greater(label, max_mask)
label = np.expand_dims(label, axis=0)
return label
评论列表
文章目录