Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clloss can not be used alone, and keep 0 all the time. #17

Closed
coreeey opened this issue Dec 2, 2021 · 2 comments
Closed

clloss can not be used alone, and keep 0 all the time. #17

coreeey opened this issue Dec 2, 2021 · 2 comments

Comments

@coreeey
Copy link

coreeey commented Dec 2, 2021

When i use the cldice to train a vessel segmentation network, i find that the cldice keeps 0 all the time.

class soft_cldice(nn.Module):
def init(self, iter_=3, smooth = 1.):
super(soft_cldice, self).init()
self.iter = iter_
self.smooth = smooth

def forward(self, y_pred, y_true):
    y_true = y_true.contiguous().unsqueeze(1).to(float) # to get the true label
    y_pred = (y_pred > 0.5).contiguous().to(float).requires_grad_() #to get the pred mask
    skel_pred = soft_skel(y_pred, self.iter)
    skel_true = soft_skel(y_true, self.iter)
    tprec = (torch.sum(torch.multiply(skel_pred, y_true)[:,1:,...])+self.smooth)/(torch.sum(skel_pred[:,1:,...])+self.smooth)    
    tsens = (torch.sum(torch.multiply(skel_true, y_pred)[:,1:,...])+self.smooth)/(torch.sum(skel_true[:,1:,...])+self.smooth)    
    cl_dice = 1.- 2.0*(tprec*tsens)/(tprec+tsens)
    return cl_dice
@jocpae
Copy link
Owner

jocpae commented Jan 30, 2022

Dear Coreey,
it is hard to comment on this without more detail. What kind of data are you using? What is the diameter of your foreground vessels? Maybe try to increase the number of iterations as a first step and plot the resulting skeletons. Otherwise I would need more specifics.

@jocpae
Copy link
Owner

jocpae commented Feb 14, 2022

To be clear we also describe this in the paper. You should always combine cldice-loss with another loss function. Please see the paper for this.

@jocpae jocpae closed this as completed Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants