Giter VIP home page Giter VIP logo

hausdorffloss's People

Contributors

patryg99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hausdorffloss's Issues

Cal the HausdorffLoss is toooooo large

Hello,
I have tried to use HausdirffDTLoss as Lossfunction.
However, the result for HausdirffDTLoss is too large.
For example:

output = np.zeros((3,3,512,512))
output[:,:,100:200,100:200] =1
output[:,:,300:500,300:500] =0.5
output_t = torch.tensor(output)
label = np.zeros((3,3,512,512))
label[:,:,100:200,100:200] =1
label_t = torch.tensor(label)
HD_loss =HausdorffDTLoss()
result = HD_loss(output_t,label_t)

the result is 6642.6849.

It is too huge.Did I do something wrong? Or do you have some method to normalize them into 0-1?

Thanks

about gradient

I'm sorry to bother you.
I have a question,you use torch.no_grad() in function distance_field,The whole process is pre->pre_dt->loss, Doesn't torch.no_grad() truncate the gradient?Why add this operation can also be trained?Doesn't pred.cpu().numpy().float() truncate the gradient?
I'm very confused about this and look forward to your reply and answer

Consulting about HD loss

Sorry for bothering you again. Recently, based on TransUnet, I am doing vessel image segmentation (the extreme imbalanced problem, the example of the ground truth is attached). I tried used the Hoausdorff Loss that you provided (total loss = loss_HD + alpha * loss_Dice, where alpha = mean(loss_HD)/mean(loss_Dice)) as described in the original paper.
The training loss curve is attached. In the first iteration, loss_HD = 4534 and loss_Dice = 0.55. In the second iteration, loss_HD = 0.0058 and loss_Dice = 0.5. In the third iteration, loss_HD = 0.0018 and loss_Dice = 0.5. In the training, I found that from the second iteration, all the prediction results are the background (i.e. the images are black, and it did not find the vessel). And in the testing process, all the prediction results are the background.
I have tried my best but still can not find where I am wrong. Could you please give me some advice? Is it because total loss can't handle extreme imbalance problem? Thanks.
CHAI CONG JUAN_00219_098 10-gt
CHAI CONG JUAN_00079_035 10-gt
Loss

3D Kernel Shape

I have a question regarding your 3D kernel shape.
The shape of your 3D kernel is 3, 1, 3, 3 I'm not sure but shouldn't the shape be 1, 3, 3, 3? The first dimension should be the channel, followed by D x H x W or not? At the Moment your kernel is D x C x H x W if I'm not completely mistaken. The reason is:

self.kernel3D = np.array([bound, cross, bound]) * (1 / 7)
# should be
self.kernel3D = np.stack([bound, cross, bound], 1) * (1 / 7)

If the shape of the kernel is on purpose I would like to understand the idea behind it :)
Thanks a lot for your work.

Best regards,
Chris

The Question about the HausdorffLoss

Thanks so much for this wonderful work. I learned a lot from this work. But I have a question about it, i.e. in hausdorff_loss.py, there have:
def distance_field(self, img: np.ndarray) -> np.ndarray:
field = np.zeros_like(img)

    for batch in range(len(img)): 
        fg_mask = img[batch] > 0.5  

        if fg_mask.any():  
            bg_mask = ~fg_mask  

            fg_dist = edt(fg_mask)  
            bg_dist = edt(bg_mask)

            field[batch] = fg_dist + bg_dist

    return field

My question is why field[batch] is the sum of fg_dist, bg_dist? The only fg_dist is not enough? Thank you in advance. Hope to hear from you as soon as possible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.