HuXiaoling/TopoLoss

Error in constructor Bitmap_cubical_complex_base

onealbao opened this issue · 4 comments

Hello, thanks so much for sharing this decent work. I'm trying to integrate the topoloss_pytorch.py into deeplab_v3 (https://github.com/chenxi116/DeepLabv3.pytorch).

The target tensor is [ 0 1 255] b/c my label only has background (0) and membrane label (1), 255 is ignored when calculating CrossEntropyLoss. The output tensor is a probability map with a value something like [-43.70812 -43.228703 -42.97284 ... 54.40196 54.60862 55.549427].

When I tried to input the target and output tensor into the topoloss, the whole pipeline crashed with the following error.

Error in constructor Bitmap_cubical_complex_base ( std::vector<std::size_t> sizes_in_following_directions, std::vector<T> top_dimensional_cells ). Number of top dimensional elements that follow from sizes_in_following_directions vector is different than the size of top_dimensional_cells vector.
terminate called after throwing an instance of 'char const*'
Aborted

It seems that the error is from

# Get the critical points of predictions and ground truth
pd_lh, bcp_lh, dcp_lh, pairs_lh_pa = getCriticalPoints(lh_patch)

but there is no further instruction. Have you ever seen this exception? Many thanks!

Sorry that I didn't come across this kind of errors before. Would you please try to test your tensors/images with this offline version topoloss first? If you still have any problems, please try to post them here.

Thanks so much for the prompt feedback. I've tried the offline version of topoloss, but got the same error about 'Error in constructor Bitmap_cubical_complex_base'.

It seems that the exception is from

lh_cubic = gd.CubicalComplex(

I've forked your repository and uploaded two sample images (gt.png and out.png) there for testing purposes at https://github.com/onealbao/TopoLoss. Maybe there is something wrong with my data input? Thanks a ton!

Quick update, it looks like the problem is because of my label value. The segmentation line needs to be 255 and the background is 0. The offline version works. I'll try the PyTorch version and back to post here then, thanks!

#10 Sorry for this bug. Please try to use the correct version.