def preprocess_labels(label):
"""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(3):
aux = np.array(Image.open(label[j][i]), dtype=np.uint8)
crop = aux[int(float(x_bb[j])):int((float(x_bb[j])+80)), int(float(y_bb[j])): int((float(y_bb[j])+80))]
labels[j].append(crop)
label = np.array(labels[0])
label = label.transpose((1,2,0))
label = label[:, :, ::-1]
max_mask = np.max(label) * 0.5
label = np.greater(label, max_mask)
label = np.expand_dims(label, axis=0)
return label
评论列表
文章目录