HuXiaoling / TopoLoss

Code for the NeurIPS 2019 paper: Topology-Preserving Deep Image Segmentation
MIT License
146 stars 22 forks source link

Q: I am confused the implement of topoloss. In your code, you mentioned that " Calculate the topology loss of the predicted image and ground truth image Warning: To make sure the topology loss is able to back-propagation, likelihood tensor requires to clone before detach from GPUs. In the end, you can hook the likelihood tensor to GPUs device." #8

Closed BaochangZhang closed 2 years ago

BaochangZhang commented 2 years ago

if the tensor have been detached from the CNN-graph in GPU and convert to numpy, then the loss is calculated. How to make sure the topology loss is able to back-propagation. here also have some comments on this question: https://discuss.pytorch.org/t/how-to-use-external-libraries-like-opencv-numpy-scipy-etc-in-middle-of-forward-backward-phase/31066

Thanks, looking forward your respond.

HuXiaoling commented 2 years ago

Remove the clone and detach operation should also work. FYI: https://discuss.pytorch.org/t/custom-loss-functions/29387/7.