class SurfaceLoss(): ''' Boundary loss implementation Inputs: @probs: probability maps…
Jump to turn (10)
- 1class SurfaceLoss(): ''' Boundary loss implementation Inputs: @probs: probabilit
- 2I have a binary segementation problem, so how would I initialise this
- 3Write me code to calculate distance maps
- 4Cell In[27], line 85, in calculatedistancemaps(targetmasks) 83 distancemaps = np
- 5Cell In[33], line 102, in customloss(pred, target) 100 a = iouloss(pred, target)
- 6AssertionError Traceback (most recent call last) Cell In[43], line 1 ----> 1 pri
- 7I'm passing in a mask with only 0 and 1 values, so I don't see the problme
- 8torch.Size([1, 1, 456, 342]) torch.Size([1, 456, 342]) tensor([[[0., 0., 0., ...
- 9Cell In[51], line 78, in calculatedistancemaps(targetmasks) 76 foregroundindices
- 10I'm getting the same error again
- User
class SurfaceLoss(): ''' Boundary loss implementation Inputs: @probs: probability maps provded from the output of the network @dc: distance maps computed when the dataset class is initialized outputs: @loss: boundary loss @description: the loss finetunes the probability maps by the groundtruth distance map representations. ''' def init(self, **kwargs): # Self.idc is used to filter out some classes of the target mask. Use fancy indexing self.idc: List[int] = kwargs["idc"] print(f"Initialized {self.class.name} with {kwargs}")
codedef __call__(self, probs: Tensor, dist_maps: Tensor, _: Tensor) -> Tensor: assert simplex(probs) assert not one_hot(dist_maps) pc = probs[:, self.idc, ...].type(torch.float32) dc = dist_maps[:, self.idc, ...].type(torch.float32) multipled = einsum("bcwh,bcwh->bcwh", pc, dc) loss = multipled.mean() return lossHow do i use this loss function