DiceLoss
·
컴퓨터 비전/개념
Dice Loss는 이미지 분할에서 사용되는 손실 함수로서, predicted mask와 ground turth mask가 얼마나 겹치는 지를 수학적으로 표현한 것이다.원래는 생물학 분야에서 세포 분할의 유사도를 평가하기 위한 개념으로 사용되었지만(Dice Similarity Coefficient), 현재는 Computer vision 분야에서도 많이 사용된다.Dice Coefficient (유사도 계수)2진 분류를 기준으로 Dice 계수의 수식적 정의는 다음과 같다.$$ Dice = \frac{2|A\cap{B}|}{|A| + |B|} $$$A$: predicted mask$B$: ground truth$|A \cap{B}|$: True positive 즉, 겹치는 정도를 0~1로 정규화한 값으로 1에..
IoU 함수
·
컴퓨터 비전/개념
토이 프로젝트를 하다가 IoU 함수가 제대로 동작하지 않는 것을 확인했다. 그래서 이참에 복습 겸 직접 IoU 함수를 작성해봤다. import torchdef iou_components(preds, targets, num_class, ignore_index=None): """ Calcualate intersection and union(IoU) value for segmentation. Args: preds (torch.Tensor): model prediction tensor(B, H, W). Each pixels in [0, num_class-1] targets (torch.Tensor): Ground truth mask tensor(B, H, W). Each pixels in [0, num_c..