plemeri / UACANet

Official PyTorch implementation of UACANet: Uncertainty Augmented Context Attention for Polyp Segmentation (ACMMM 2021)
MIT License
142 stars 37 forks source link

Some questions about the ‘bce_iou_loss’ function #6

Closed Liqq1 closed 2 years ago

Liqq1 commented 2 years ago
def bce_iou_loss(pred, mask):
    weight = 1 + 5 * torch.abs(F.avg_pool2d(mask, kernel_size=31, stride=1, padding=15) - mask)

    bce = F.binary_cross_entropy_with_logits(pred, mask, reduction='none')

    pred = torch.sigmoid(pred)
    inter = pred * mask
    union = pred + mask
    iou = 1 - (inter + 1) / (union - inter + 1)

    weighted_bce = (weight * bce).sum(dim=(2, 3)) / weight.sum(dim=(2, 3))
    weighted_iou = (weight * iou).sum(dim=(2, 3)) / weight.sum(dim=(2, 3))

    return (weighted_bce + weighted_iou).mean()

question

I am looking forward to your reply!

plemeri commented 2 years ago

Sorry for the late reply. As we used PraNet as our baseline, we thought the loss function was also from them. In Fact, the authors of PraNet referred F3Net which proposed the loss function that we used, and we should have referred them too.

Long story short, sorry that we mislead some information, please refer to F3Net for more information.

Liqq1 commented 2 years ago

Thanks for your reply, I will refer to F3Net for more information~