Git Product home page Git Product logo

topoloss's People

Contributors

huxiaoling 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  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  avatar  avatar  avatar

topoloss's Issues

Compiling the library in macOS

I can successfully run TDFMain.py using Python 2.7 with the PersistencePython.so file in this repo. However, I'd like to use Python3. When I run the compile_pers_lib.sh I get the following error:

(...)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The "(...)" stands for a long list of frameworks needed. Perhaps you have a Python 3 version you could please share?

true 3D code

Thank you very much for your contribution,
I would like to ask when true 3D code will be released ?
Because most medical images are 3D.

A Question about the paper

Hello, I just wonder that why three points wouldn't overlap together in this figure (b)'Dgm(g)', since birth and dead time of them are the same.
image

Many thanks,

free(): double free detected in tcache 2

Hi Xiaoling!

Thank you for the impressive work! I had some trouble when incorporating the TopoLoss into my model training. Specifically, I have two questions

  • Is the function getTopoLoss() intended for processing single image pairs? I would kindly like to know the shape of the two inputs, likelihood_tensor and gt_tensor, in PyTorch.
  • I met an error called "free(): double free detected in tcache 2" during training. Do you happen to have any idea about this error?

Thank you in advance!

Example call of CubicalPers_gcc

Can you please provide an example file for calling the executable CubicalPers_gcc?
usage: ./CubicalPers_gcc input_file.ext

How to calculate β-error?

it's not very clear in you paper about how to calculate β-error? And I can't find the code in your github too.
Could you release the code?
Thank you.

Debug problems

Hello!
First of all thanks for sharing your code.
Use your topological loss as follows: loss = nn.CrossEntropyLoss() + lambda * getTopoLoss(lh, gt).
In the process of code debugging, there are several questions I would like to ask you:

  1. The gt image has only a single connected domain. Is it not recommended to block the image, otherwise it cannot be guaranteed that the connected domains after the block are continuous on the overall image;
  2. If the image needs to be divided into blocks, whether it is necessary to mark the background color around the divided image, there seems to be no such part in topoloss.py;
  3. lh_cubic.persistence(homology_coeff_field=2, min_persistence=0), whether the min_persistence here needs to be debugged for the input image.

At present, during the running of the code, I don't know if the topological constraint is not very effective because gt has only one connected domain.
Looking forward to your reply.

About betti error

Hi, sorry to bother you again. Can you provide the details of computing BETTI error? I saw that in cldice, they computed the betti error on random 64*64 patches. Did you do the experiments under the same setting?

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."

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.

IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed

hi, Dr Hu. Recently, I have been tried to run your Topoloss.py in my own network.

The shape of input tensor is [4, 2, 512, 512], and the shape of label tensor is [4, 512, 512]. I want to traverse four images in a batch and calculate their average loss, so I wrote the following code:
image

At the beginning, i can successfully run the code while the speed was very slow (because it had to be calculated on the CPU).
Later, during the 14000 iteration, it suddenly reported the following error:
image

I guess it should be resulted by the certain image calculated homology features only have 0-dimension (points) and not have 1-dimension (loops).

Can you give me some guidance? Thanks!

problem about "cofaces_of_persistence_pairs"

hi, I'm running topoloss.py, but I have a problem.
My input image has 7 holes, but the calculation results of len(pairs_lh[0][0]) is only 6, and bcp_lh and dcp_lh are 6 too.
At the same time, note that the starting and ending points of bcp_lh and dcp_lh do not correspond.
No matter how I change pictures, the number will always be one less.
I want to ask, is this a gudhi library problem or a debugging problem?

Compiling the library in windows

I have tried to import the module by placing the .so file in the working directory. I am getting an importerror. I am using windows os and python 3.7. When I run the compile_pers_lib.sh, .so file is getting generated. But still it throws an error saying that it is not a DLL application built on Windows. How to import the module in Windows system?

Boundary mask of CREMI dataset

Hello, how did you get the boundary mask of CREMI dataset? It only provides the neuron_ids. I can extract the boundareis by applying skimage.segmentation.find_boundarys on neuron_ids. But I got boundaries which seem thinner than what you have shown in paper. Did you add something such as a Gaussian blur? Thanks!

Why is ARI and VOI topology-aware

Any proof? It seems that these are pixel-based metrics that only use 4 basic partitions(TP, FP, TN, FN). And I have not found any related literature before yours claiming that ARI and VOI are related to topology correctness.
In fact, ARI is first used as an acronym for Adapted Rand Index in the CREMI (https://cremi.org/) official metric. On their website, they are also mentioned as pixel-based measures.

A problem of constructing topo_cp_weight_map

In

topo_cp_weight_map[y + int(bcp_lh[hole_indx][0]), x + int(
,
I wonder why the index is y + int(bcp_lh[hole_indx][0]), x + int(bcp_lh[hole_indx][1])?
It seems that the topo_cp_weight_map has the same shape as likehood, and bcp_lh is the list of the global indices instead of local indices in current patch. x and y is the starting global index of current patch. Will this (x + int(bcp_lh[hole_indx][1]) lead to some "segmentation fault" problem?

Not clear how to use

Hi,

I assume this is the code for "Topology-Preserving Deep Image Segmentation" published at NeurIPS last week. This code only includes specific function and includes python functions rather than pytorch or tensorflow implementations? Would appreciate if you could point on how one is supposed to get started with this code.

Indentation issue in topoloss_pytorch.py

Hello, @HuXiaoling.
Thank you for providing this code! I just have a question about the getTopoLoss function on the topoloss_pytorch.py script:

The lines 220-225:

topo_cp_weight_map = torch.tensor(topo_cp_weight_map, dtype=torch.float).cuda()
topo_cp_ref_map = torch.tensor(topo_cp_ref_map, dtype=torch.float).cuda()
# Measuring the MSE loss between predicted critical points and reference critical points
loss_topo = (((likelihood_tensor * topo_cp_weight_map) - topo_cp_ref_map) ** 2).sum()
return loss_topo
have 2 indentations, which means that they are currently inside the for loop in line 160:
for y in range(0, likelihood.shape[0], topo_size):

Shouldn't they be outside the y for loop to get the total topological loss for the image?

Error in constructor Bitmap_cubical_complex_base

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!

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.