-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Implementation of boundary-aware ShapeLoss #4205
base: dev
Are you sure you want to change the base?
Conversation
Signed-off-by: Arnaud Dhaene <arnaud.dhaene@epfl.ch>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the PR, I put some initial comments inline, please ignore them if you are already working on these aspects...
>>> target = one_hot(target_idx[:, None, ...], num_classes=C) | ||
>>> self = ShapeLoss(reduction='none') | ||
>>> loss = self(input, target) | ||
>>> assert np.broadcast_shapes(loss.shape, input.shape) == input.shape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be great to create a test case for this class, you can follow this one https://github.com/Project-MONAI/MONAI/blob/dev/tests/test_local_normalized_cross_correlation_loss.py
you can run a single test case within the codebase:
pip install -U -r requirements-dev.txt # install testing tools
python -m tests.test_local_normalized_cross_correlation_loss
* more specific class name * data conversion using `monai.utils` * distance transform import using `optional_import` * TODO: test case
Hi @arnauddhaene, thanks for this PR. It will be very useful for the community, as distance transform losses do generally improve HD and Dice. I have a doubt though, I see in code there is distance tranform being calculated in numpy. If that is the case, how will the backpropagation work in the training? |
Hi @Bala93, thank you! We do not need to backprop on the distance transform. We are in essence transforming the ground truth to a non-binary mask that will penalize the network for boundary misclassification. The result of the transform is compared to the logits produced by the network, and the difference is used as loss to update the network's weights via backprop. In fact, the I hope this answers your question. |
* updated scikit-image morphology module deprecation * updated reception of converted numpy array
Hi @arnauddhaene, is there any more progress on this PR so far, do you plan to finish this one? |
Why no use distance_transform_edt from monai.transforms that use cupy/cucim with GPU instead slow CPU scipy? Can add PR if someone want. |
Signed off by: Arnaud Dhaene arnaud.dhaene@epfl.ch
Fixes #4204
Description
An implementation of a slight variation of the boundary-aware
ShapeLoss
described in Huang et al., 2021.Status
Work in progress: the feature has been implemented, but unit testing needs to be added.
Types of changes
./runtests.sh -f -u --net --coverage
../runtests.sh --quick --unittests --disttests
.make html
command in thedocs/
folder.