Giter Site home page Giter Site logo

cvlab-epfl / voxel2mesh Goto Github PK

View Code? Open in Web Editor NEW
151.0 12.0 35.0 1.47 MB

Voxel2Mesh: 3D Mesh Model Generation from Volumetric Data

License: GNU General Public License v3.0

Python 84.07% C++ 1.67% Cuda 14.26%
volumetric-data 3d-surfaces mesh-networks mesh-generation

voxel2mesh's Introduction

Voxel2Mesh: 3D Mesh Model Generation from Volumetric Data

This repository is a PyTorch implementation of Voxel2Mesh architecture proposed in Voxel2Mesh: 3D Mesh Model Generation from Volumetric Data; Udaranga Wickramasinghe, Edoardo Remelli, Graham Knott and Pascal Fua; MICCAI 2020.

Abstract

CNN-based volumetric methods that label individual voxels now dominate the field of biomedical segmentation. However, 3D surface representations are often required for proper analysis. They can be obtained by post-processing the labeled volumes which typically introduces artifacts and prevents end-to-end training. In this paper, we therefore introduce a novel architecture that goes directly from 3D image volumes to 3D surfaces without post-processing and with better accuracy than current methods. We evaluate it on Electron Microscopy and MRI brain images as well as CT liver scans. We will show that it outperforms state-of-the-art segmentation methods.

Architecture

Fig. 1. Architectures (a) The Pixel2Mesh-3D architecture, a straightforward extension of [20], uses a surface decoder but no voxel decoder. (b) By contrast, our Voxel2Mesh architecture takes as input an image and spherical mesh. They are jointly encoded and then decoded into cubes and meshes of increasing resolution. At each mesh decoding stage, the decoder first receives as input the current mesh and a set of features sampled from the cube of corresponding resolution. Then the mesh is deformed and refined non-uniformly by adding vertices only where they are needed.

Fig. 2. Qualitative results. (a) Input volumes. EM (row 1,2), CT(row 3), MRI(row 4) (b) Ground truth (c) CNN baseline (d) CNN baseline + post processing (e) Voxel2Mesh. The orange boxes highlight false positive regions.

Installation

PyTorch 1.4

Python 3.6.9

Update: You can use the enviroment.yaml file created by ctr26 to find the necessary packages.

Dataset

 1. CHAOS dataset .

 2. Hippocampus dataset. Missing dataset_init function to generate .npy files: #7

 3. Synaptic junction dataset.

Running Experiments

  Step 1: Update config.py. You need to set the path to the dataset and also the directory to save the results.

  Step 2: If it is the first time, you need to pre-process the data. For that execute python data_preprocess.py. Pre-processed data will be save at the dataset directory.

  Step 3: Now execute python main.py and this will start training the network.

Known Issues

GPU memory limitations

For our experiments, we used a GPU with 32GB of memory. If you are using a GPU with memory less than 20GB, you might run out of GPU memory during evaluation stage since we use higher number of vertices at this stage. To reduce the number of vertices during evaluation stage, you can reduce the number of mesh unpoolings (sub-divisions) specified at line 128 in data.py. For instance you can change 'unpool':[0, 1, 1, 1, 1] to 'unpool':[0, 1, 0, 1, 1] or 'unpool':[0, 1, 0, 1, 0]

Order of slices in loaded image stacks

In some systems, order of the slices in the loaded image stack can be shuffled. This issue was first reported by Patrick Jenson and he proposed a solution here

Missing faces on output mesh

This happens due to the vertex order in the face matrix. In the meshes produced by Voxel2Mesh, some faces have vertices in clockwise direction and others have them in anti-clockwise direciton. This could be easily fixed by setting the 'back-face' color of the faces in your mesh viewer same as the 'front-face' color OR by writing a function to correct the orientations of the faces.

Citation

If you find Voxel2Mesh useful, please cite the MICCAI article

@InProceedings{10.1007/978-3-030-59719-1_30,
author="Wickramasinghe, Udaranga and Remelli, Edoardo and Knott, Graham and Fua, Pascal",
title="Voxel2Mesh: 3D Mesh Model Generation from Volumetric Data",
booktitle="Medical Image Computing and Computer Assisted Intervention -- MICCAI 2020",
year="2020",
publisher="Springer International Publishing",
address="Cham",
pages="299--308", 
isbn="978-3-030-59719-1"
}

Contact

For any questions regard this paper/code, please make a post in Issues.

voxel2mesh's People

Contributors

afoix avatar udaranga3001 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

voxel2mesh's Issues

how should i operate Synaptic junction dataset.

hello i want to try your code but i had a question of operating dataset for Synaptic junction dataset. It looked like you made specific calls for chaos and hippocampus but not synaptic junction dataset. Should I make one for this dataset? thank you

Use voxel2mesh in another dataset, continuing #11

The initial issue was #11 I am reopening an issue for further clarification if that's OK, @udaranga3001 😊

Thank you for confirming the structure of the code. Now, what is left as a question mark is the way one goes about implementing the pre_process_dataset method. Given the currently available resources I found in the repo, I would have to already be familiar with the structure of the Chaos dataset or of the Hippocampus dataset to have a shot at then understanding what it is that they do in their implementation of the pre_process_dataset method, hope that this clarifies the structure of the pickle file, and only then be able to start trying to populate a pickle file for an arbitrary other dataset. This is what I would like to avoid. One helpful step here would be a more readily accessible piece of documentation describing the expected format of the pickle file (its byte structure).

Hopefully you can provide some clarifications along these lines?

Thank you again for your help

How to run model with Hippocampus dataset?

Hi,

This looks like interesting work! Could you provide instructions on how the code in this repository can be modified to work with the Hippocampus dataset?

The code in main.py appears to run Chaos() on line 73, which then tries to preprocess DICOM files from the chaos dataset.

It would be wonderful to try Voxel2Mesh on the Hippocampus dataset or other .nii files.

Thank you!

Modification about "Anisotropic" Setting

Hi Dr.Udaranga, I saw the data that Voxel2mesh used was all preprocessed to have the same pixel resolution in X, Y, and Z dim(i.e. isotropic). While the common situation is dim of X, Y, Z is not same(i.e anisotropic). So is it possible to make a modification of Voxel2Mesh: replace the isotropic conv with anisotropic conv? Is it necessary to replace the current 3D sphere template with other anisotropic geometry such as ellipsoid?

Use voxel2mesh in another dataset

Hello,

I am interested to try voxel2mesh on different datasets. I have been trying to find instructions regarding how to interface with the tool. So far, I ended up having a read through the high level python files in the repo to get a sense of how to do that instead.

So far, my understanding is that an object is to be provided for the cfg.data_obj field (config.py).

Two examples are provided: Chaos and Hippocampus.
Reading a bit further, in the data/ folder, we find definition for those classes as well as a data.py.
Although this is not explicit, it looks like the class DatasetAndSupport (https://github.com/cvlab-epfl/voxel2mesh/blob/master/data/data.py#L30-L40) is a blueprint for the expected interface (probably intended as an abstract class to be inherited from like Hippocampus does https://github.com/cvlab-epfl/voxel2mesh/blob/master/data/hippocampus.py#L50)

Reading a bit further yet, it look like the main expects the quick_load_data (https://github.com/cvlab-epfl/voxel2mesh/blob/master/main.py#L76) to be defined, which in turn seems to expect that a pickle file exists (https://github.com/cvlab-epfl/voxel2mesh/blob/master/data/hippocampus.py#L58 and presumably similar in chaos). This pickle file appears to be generated upon running pre_process_dataset (https://github.com/cvlab-epfl/voxel2mesh/blob/master/data/hippocampus.py#L66) which I would guess is the only really dataset-specific chunk of code...?

I would like to avoid trying to understand the shape of the files in hippocampus and in chaos to then infer what lands in the Sample objects which seem to be the things that ultimately get serialised in the pickle file. Could you provide information regarding what the expected format is, and how one would go about producing it from a set of images?

Thank you for your help.

Comparative Experiment

Hello, author, I would like to inquire about the Pixel2Mesh-3D mentioned in your comparison experiment, whether you can provide this part of the code. My email address is [email protected]. I would appreciate it if you could help me, best wishes to you.

File "<__array_function__ internals>", line 180, in concatenate ValueError: need at least one array to concatenate

Hi I am trying to run the file and put down the path for hippocampus dataset, and as a result, I see the error as stated in the title. Is there some additional lines that need to be put? Thank you

Traceback (most recent call last):
File "data_preprocess.py", line 43, in
main()
File "data_preprocess.py", line 39, in main
data = data_obj.pre_process_dataset(cfg)
File "/home/cs2212/Desktop/voxel2mesh-master/data/hippocampus.py", line 97, in pre_process_dataset
inputs_ = np.concatenate(inputs_, axis=0)
File "<array_function internals>", line 180, in concatenate
ValueError: need at least one array to concatenate

utils_voxel2mesh module missing

Hi,

I am trying to run this project, it seems that the utils.utils_voxel2mesh module is missingfrom this repository. Multiple files are importing it, but mainly the voxel2mesh.py can't work without it:

from utils.utils_voxel2mesh.graph_conv import adjacency_matrix, Features2Features, Feature2VertexLayer
from utils.utils_voxel2mesh.feature_sampling import LearntNeighbourhoodSampling
from utils.utils_voxel2mesh.file_handle import read_obj
from utils.utils_voxel2mesh.unpooling import uniform_unpool, adoptive_unpool

Is there a way you can commit this?

Thank you!

ImportError: libtorch_cpu.so: cannot open shared object file: No such file or directory

Hello,

I am trying to implement Voxel2Mesh with Hippocampus dataset.

Firstly, I want to execute data_proprocess.py.

But I have this error.

Using /tmp/torch_extensions as PyTorch extensions root...
Detected CUDA files, patching ldflags
Emitting ninja build file /tmp/torch_extensions/rasterize_cuda/build.ninja...
Building extension module rasterize_cuda...
ninja: no work to do.
Loading extension module rasterize_cuda...
Traceback (most recent call last):
  File "data_preprocess.py", line 24, in <module>
    from model.voxel2mesh import Voxel2Mesh as network
  File "/home/hanwool/git/voxel2mesh/model/voxel2mesh.py", line 6, in <module>
    from pytorch3d.ops import sample_points_from_meshes
  File "/home/hanwool/.local/lib/python3.6/site-packages/pytorch3d/ops/__init__.py", line 5, in <module>
    from .graph_conv import GraphConv
  File "/home/hanwool/.local/lib/python3.6/site-packages/pytorch3d/ops/graph_conv.py", line 8, in <module>
    from pytorch3d import _C
ImportError: libtorch_cpu.so: cannot open shared object file: No such file or directory

I use Pytorch version 1.4.0, CUDA 10.1 and Python version: 3.6.
I use pytorch3d 0.2.0 version.

Do you know why this error occurs?

Train Voxel2Mesh on own data

Is it possible to train Voxel2Mesh on my own training data, which consists of 3D voxelized MRI scans?
Currently, I only see Dataloaders for the CHAOS and Hippocampus datasets.

Thanks

Data preprocessing for CHAOS dataset can break.

First, thanks a lot for releasing the code!

During preprocessing of the CHAOS dataset, the xy-slices may get loaded out-of-order since os.listdir does not necessarily sort the file names. Specifically, L104 and L152 in data/chaos.py:

images_path = [dir for dir in os.listdir('{}/{}/DICOM_anon'.format(data_root, sample)) if 'dcm' in dir]

images_path = [dir for dir in os.listdir('{}/{}/Ground'.format(data_root, sample)) if 'png' in dir]

This messes up the data since the xy-slices are then in the wrong order. Calling sorted on images_path seems to fix it.

RuntimeError:No surface found at the given iso value.

Hello, thank you very much for your work. I encountered an error during the evaluation process while using my own dataset (in nii.gz format). When I printed the matrix, I found that it was all zeros. I haven't been able to identify the problem yet. Would you be able to assist me with this issue? Thank you.


ImportError: /home/cs2212/.local/lib/python3.8/site-packages/pytorch3d/_C.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZTIN3c1021AutogradMetaInterfaceE

Hi I am trying to run the program, but as I run the files, i get the error as stated in the title. The current environment is cuda 10.1 from nvcc --version, torch is 1.11.0+cu113, and python 3.8.10 and pytorch3d 0.1.1.
The below shows the error i am getting:
Traceback (most recent call last):
File "data_preprocess.py", line 24, in
from model.voxel2mesh import Voxel2Mesh as network
File "/home/cs2212/Desktop/voxel2mesh-master/model/voxel2mesh.py", line 6, in
from pytorch3d.ops import sample_points_from_meshes
File "/home/cs2212/.local/lib/python3.8/site-packages/pytorch3d/ops/init.py", line 5, in
from .graph_conv import GraphConv
File "/home/cs2212/.local/lib/python3.8/site-packages/pytorch3d/ops/graph_conv.py", line 10, in
from pytorch3d import _C
ImportError: /home/cs2212/.local/lib/python3.8/site-packages/pytorch3d/_C.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZTIN3c1021AutogradMetaInterfaceE

Do you have any tips on how i should solve this? Thank you

batch_size setting

Could I run the code in larger batch_size? I saw in the config.py, the comment wrote"Only supports batch size 1 at the moment. "

data preprocess as "Chaos.py" example

Hi Dr.Udaranga, there is a question about data preprocessing when I referred "Chaos.py" as the template preprocess script, in "Chaos.py" Line 82, and Line143, there are two "crop" functions were used, are they replicated? Could I remove one of them?

image
image

Data dimensions are not the same in my own dataset.

If the data used undergoes preprocessing to have the same dimensions along the XYZ axes, it might lead to distortion of the data. Could it be processed into different dimensions (for example, 32x128x128) without changing the rest of the code?

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.