You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is a binary classification problem. After using the boundary loss proposed by you, all categories are judged as the background in the output result of the network, that is, the output result is 0, and no segmentation area is found. What is the problem causing this?
This code is to find the loss function and distance graph
It is a binary classification problem. After using the boundary loss proposed by you, all categories are judged as the background in the output result of the network, that is, the output result is 0, and no segmentation area is found. What is the problem causing this?
This code is to find the loss function and distance graph
label = Image.open(os.path.join(os.path.join(self.label_path, image_name)))
label = np.array(label)
seg_label = np.eye(self.num_classes)[label.reshape([-1])]
seg_label = seg_label.reshape((int(self.input_shape[0]), int(self.input_shape[1]), self.num_classes))
seg_label = np.transpose(seg_label, [2, 0, 1])
dist_map = self.one_hot2dist(seg_label)
def one_hot2dist(self, seg_label: np.ndarray) -> np.ndarray:
"""
根据独热编码分割图像计算距离图,用于后续损失计算
:param seg:
:return:
"""
C: int = len(seg_label)
out = model(img)
----------------------#
损失计算
----------------------#
if ce_loss:
ce = CE_Loss(out, seg_labels, weights)
if focal_loss:
focal = Focal_Loss(out, seg_labels, weights)
if dice_loss:
dice = DiceLoss(out, seg_labels, idc=[0, 1])
if boundary_loss:
boundary = SurfaceLoss(out, dist_maps, idc=idc)
loss = (ce + focal + dice) * (1 - alpha) + alpha * boundary
def SurfaceLoss(inputs, dist_maps, idc=[1]):
temp_inputs = torch.softmax(inputs, dim=1)
The text was updated successfully, but these errors were encountered: