Manza12/nnMorpho

Only 2D tensor for erosion?

Opened this issue · 4 comments

First of all, thank you for putting in the effort to build a PyTorch library for morphological operations and that too with CUDA support. So, I was thinking of using the library for my research. But what I am seeing is that in the code of the master branch the comment says the erosion supports only 2D tensor. Is this the current situation?

By looking at the old commits, I understood is, the previous version had all the functions but it required a separate module morphology_cuda to use the CUDA functionality and you are trying to merge that into a single module. If so, may I help you with this? Actually, my work requires a modification to the dilation and erosion operations. I had earlier implemented them for TensorFlow, but now I need them in PyTorch and modifying your code should be easier.

I am very happy that this library is useful for you.
Let me sum up the current situation such that you have an overview:
I started by supporting all dimensions because I used PyTorch unfold to do that and it was very straightforward to do that for all dimensions, however, it is very memory consuming. This is why I thought that to split each dimension would be better.
In all the cases, I need to install a morphology_cuda module for GPU computation, but recently I also implemented the operations in C++, so there is also a morphology_cpp module to install.
Let me know which kind of morphological operation you need and then we can work together to develop it.

Actually, I am trying to implement the following paper [1] and extend it to 2D (actually, 4D for using them with a batch of RGB images). I have tried implementing using unfold and as you have said it takes a huge amount of memory. So, next, I tried using the function implemented in Kornia. The memory usage has improved but the computation is still slow. It is expected to be slower than convs, because they have been heavily optimized over the years. So, I am thinking of using your implementation. But the modification is required to implement the 'soft' version of dilation and erosion.

Now about the code. I think I have guessed wrong. So, you are currently moving all the operations to C++. The main aim is not to make them a single module. Am I right? Since I need a little modification to the existing operation, I thought, Ok let's help make this library better. Can you tell me about the current state of code? Actually, I am confused why you removed the working code and started doing things from the scratch again.

[1] Mondal, Ranjan, et al. "Morphological Network: How Far Can We Go with Morphological Neurons?." arXiv preprint arXiv:1901.00109 (2019).

I think it is cool to implement new versions of these operations. I am checking the paper.

Regarding the code: I don't know if I explained it correctly. I want to have all operations implemented in C++/CUDA (C++ for CPU and CUDA for GPU). I want also to split the operations in modules, depending on the expected input/output (greyscale/binary). Also, if you want new type of operations we can put them in other modules.

With respect with the removed code, I think I did that a bit chaotically; a better approach would have been to create a new branch. We can try to do that to let a stable version with older implementations.

Finally, I think that we might meet such that we can coordinate better. My mail is tritery@hotmail.com (once you get it I will edit this answer to remove it).

Thank you again for the interest.

Ok, I get it you mainly want to streamline things.