Coder Social home page Coder Social logo

griegler / octnet Goto Github PK

View Code? Open in Web Editor NEW
488.0 37.0 104.0 560 KB

OctNet: Learning Deep 3D Representations at High Resolutions

License: Other

Shell 0.33% CMake 2.59% C++ 36.74% C 4.31% Cuda 25.41% Lua 24.96% Python 5.65%
deep-learning 3d octree torch python

octnet's Introduction

OctNet uses efficient space partitioning structures (i.e. octrees) to reduce memory and compute requirements of 3D convolutional neural networks, thereby enabling deep learning at high resolutions.

This is the code for the paper:

OctNet: Learning Deep 3D Representations at High Resolutions
Gernot Riegler, Ali Osman Ulusoy and Andreas Geiger
CVPR 2017

We present OctNet, a representation for deep learning with sparse 3D data. In contrast to existing models, our representation enables 3D convolutional networks which are both deep and high resolution. Towards this goal, we exploit the sparsity in the input data to hierarchically partition the space using a set of unbalanced octrees where each leaf node stores a pooled feature representation. This allows to focus memory allocation and computation to the relevant dense regions and enables deeper networks without compromising resolution. We demonstrate the utility of our OctNet representation by analyzing the impact of resolution on several 3D tasks including 3D object classification, orientation estimation and point cloud labeling.

CVPR'17 Presentation

GTC'17 Presentation

If you find this code useful for your research, please cite

@inproceedings{Riegler2017OctNet,
  title={OctNet: Learning Deep 3D Representations at High Resolutions},
  author={Riegler, Gernot and Ulusoy, Ali Osman and Geiger, Andreas},
  booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
  year={2017}
}

Code Overview

  • core - This directory includes the core code for the hybrid grid-octree data structure (include/octnet/core), the CPU code for the network operations on this data structure (include/octnet/cpu), as well as some code to create test objects (include/octnet/test).
  • core_gpu - GPU (CUDA) code for the network operations.
  • create - Code to pre-process 3D data (point clouds, meshes, dense volumes) and convert it to the grid-octree structure.
  • geometry - Simple geometry routines mainly used in the create package.
  • py - This directory a small python wrapper to the create package and some core functions.
  • th - A full featured torch wrapper for all network operations.
  • example - Contains an example to create data and train a network on ModelNet10.

Requirements

We tried to keep the requirements small. To build the individual projects you will need:

  • cmake to setup the projects
  • gcc, or clang to build the core project
  • nvcc (CUDA) to compile the GPU network operations
  • cython to compile the Python wrapper
  • torch to setup the torch wrapper

Optionally, you will need

  • OpenMP for the parallelization of the CPU functions

Build

The building process of the individual packages should be fairly easy. All packages, except the Python wrapper py, are cmake projects. Therefore, you can create a build directory in the individual package folder and call cmake and make. For example, to build the core package:

cd core
mkdir build
cd build
cmake ..
make -j

To build the Python wrapper just do

cd py
python setup.py build_ext --inplace

If you do not want to repeat this for all the packages, we provide two simple bash scripts that automate this process:

  • build_cpu.sh - builds all the CPU code for OctNet
  • build_all.sh - same as above, but also builds the GPU network functions and the GPU wrapper code for torch

octnet's People

Contributors

ejshim avatar griegler avatar qinka 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  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

octnet's Issues

error when loading the octree data??

below is the script i am doing testing stuff on loading octree data:

package.path  = package.path ..  ';'.. '/home/name/project/octnet/th/oc/init.lua'
require 'oc'
data_cpu = oc.FloatOctree() -- works okay 
data_cpu:read_from_bin_batch({'./test_octrees/chair_128.oc'}) -- okay 
data_cpu:data( )  -- error!!!

It gives the following error. can you fix it??

octnet/th/oc/octree.lua:300: attempt to index global 'th' (a nil value)
stack traceback:
        ...w/project_work_on/shape_research/octnet/th/oc/octree.lua:300: in function 'data'
        [string "_RESULT={data_cpu:data() }"]:1: in main chunk
        [C]: in function 'xpcall'
        /home/hxw/torch/install/share/lua/5.1/trepl/init.lua:661: in function 'repl'
        .../hxw/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:204: in main chunk
        [C]: at 0x00406670

help with creating octree from pcl point clouds

Hi,
I'm trying to create octrees with pcl organised point clouds. What I'm stuck with is what does the ranges and number of ranges mean in the octree_create_from_dense_cpu mean in terms of point clouds and how I procure those from a raw point cloud. If possible. Could you post a code example on how to convert raw pcl pointclouds to octrees.

Get Occupancy of an octree to be used to create a octree of different data

What method do I use in python to get the occupancy of an octree? I want to use that octree to create an octree of a different dense array to have to same structure as the first. I can see that create_from_dense_2 lets me do that, but I don't see a function to get the occupancy of the first octree.
Thank You

BatchSize

Hello,
Increasing the batch size seems to increase the time taken for processing the batch almost by a factor of batchsize.
The only thing which I feel which influences it is the n_grids parameter.
I calculated the memory used by the output octree at each step and I found that it should take around 1gb all combined for the forward pass per input. So considering backward and network parameters, the whole thing should not take more than 2.5gb. But changing n_grids it to -1 causes it to go out of memory.
Can you please help me out?

Thanks.

Unable to run example 00_create_data

Hi, I tried to run the create_data.py file in examples/00_create_data and I got the following error :

  [OctreeCreateCpu] create octree structure
  [OctreeCreateCpu] update octree data structure
  [OctreeCreateCpu] fill data
  [OctreeCreateCpu] done
Traceback (most recent call last):
  File "./create_data.py", line 32, in <module>
    oc_from_dense2 = pyoctnet.Octree.create_from_dense2(dense, dense[np.newaxis,...], n_threads=n_threads)
  File "pyoctnet.pyx", line 644, in pyoctnet.Octree.create_from_dense2 (pyoctnet.cpp:8776)
    def create_from_dense2(cls, float[:,:,::1] occupancy, float[:,:,:,::1] features, bool fit=False, int fit_multiply=1, bool pack=False, int n_threads=1):
  File "stringsource", line 644, in View.MemoryView.memoryview_cwrapper (pyoctnet.cpp:23565)
  File "stringsource", line 345, in View.MemoryView.memoryview.__cinit__ (pyoctnet.cpp:19800)
ValueError: ndarray is not C-contiguous

Thanks for the help !

octree converted point clouds errors while training

Hi,
I tried using unorganised point clouds and I got this error at line 70 of OctreeConvolutionMM.lua

invalid input size, self.nInputPlane=1, input:feature_size()=3

I assume it's because unorganised point clouds do not have positional information of the points and hence are 1 * numofpoints instead of height * width

So I tried I using organised point clouds, and the code errors out giving before even loading the octrees completely.

feature_size of path 1 does not match in octree_read_batch_cpu (3, 1)

Both of them are related to the feature size and input plane mismatch which pushes me to believe that I'm doing a mistake while creating the octree.
I'm using python pcl to load point clouds and I convert them into numpy arrays before using create_octree_from_cpu.

import pcl
path = "./organisedpointclouds/cloud1.pcd"
p = pcl.load(path)
xyz = cloud
features = np.ones_like(xyz)
oc_from_pcl = pyoctnet.Octree.create_from_pc(xyz, features, vx_res, vx_res, vx_res, normalize=True,
n_threads=n_threads)
for idx in range(3):
xyz[..., idx] = (xyz[..., idx] - xyz[..., idx].min()) / (xyz[..., idx].max() - xyz[..., idx].min())
xyz[..., idx] *= vx_res
oc_from_pcl = pyoctnet.Octree.create_from_pc(xyz, features, vx_res, vx_res, vx_res, normalize=False,
n_threads=n_threads)
savePath = "./octrees/octree1.oc"
oc_from_pcl.write_bin(savePath)
cloud.zip

Unable to execute the training example

Hi

I have successfully compiled the octnet code on my machine. However, while executing the examples, specifically while executing this script

th train_mn10_r64.lua

, I receive the following error

/home/siddharth/.luarocks/share/lua/5.1/hdf5/init.lua:15 Unable to find the HDF5 lib we were built against - trying to find it elsewhere
/home/siddharth/torch/install/bin/luajit: /home/siddharth/torch/install/share/lua/5.1/trepl/init.lua:389: /home/siddharth/.luarocks/share/lua/5.1/hdf5/ffi.lua:29: libhdf5.so: cannot open shared object file: No such file or directory
stack traceback:
[C]: in function 'error'
/home/siddharth/torch/install/share/lua/5.1/trepl/init.lua:389: in function 'require'
../common.lua:3: in main chunk
[C]: in function 'dofile'
classification_common.lua:1: in main chunk
[C]: in function 'dofile'
train_mn10_r64.lua:3: in main chunk
[C]: in function 'dofile'
...arth/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
[C]: at 0x00405d50

Does the code have any specific dependency ?

Could NOT find CUDA while compiling

Hi,

When I run the script 'build_all.sh', The following error occurred:

CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message): Could NOT find CUDA (missing: CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (found suitable version "8.0", minimum required is "6.5") Call Stack (most recent call first): /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE) /usr/share/cmake-3.5/Modules/FindCUDA.cmake:949 (find_package_handle_standard_args) CMakeLists.txt:42 (find_package)

However, torch and cuda work very well on my machine. Do you know how to fix this? Thanks very much!

Questions about the classification network architecture

Hi,

In your released model for classification, the first six convolution layers are OctreeConvolutions, while the last four are cudnn.VolumetricConvolutions. Why don't you set all convolutions as OctreeConvolutions?

I am also wondering if you are willing to release the exact model for semantic 3D point cloud labelling. Since I am very curious how it looks like.

Thanks very much!

Error in CPU execution of 01_classification_modelnet

Hi, Firstly thanks for the prompt reply regarding the previous issue. I subsequently tried running the code in examples/01_classification_modelnet and I got this error:

~/octnet/distro/install/bin/luajit: ...hesis/octnet/distro/install/share/lua/5.1/trepl/init.lua:389: module 'cunn' not found:No LuaRocks module found for cunn
        no field package.preload['cunn']
        no file '../../th/cunn/init.lua'
        no file '~/.luarocks/share/lua/5.1/cunn.lua'
        no file '~/.luarocks/share/lua/5.1/cunn/init.lua'
        no file '~/thesis/octnet/distro/install/share/lua/5.1/cunn.lua'
        no file '~/thesis/octnet/distro/install/share/lua/5.1/cunn/init.lua'
        no file './cunn.lua'
        no file '~/thesis/octnet/distro/install/share/luajit-2.1.0-beta1/cunn.lua'
        no file '/usr/local/share/lua/5.1/cunn.lua'
        no file '/usr/local/share/lua/5.1/cunn/init.lua'
        no file '/cis/home/msid/.luarocks/lib/lua/5.1/cunn.so'
        no file '/cis/home/msid/thesis/octnet/distro/install/lib/lua/5.1/cunn.so'
        no file '/cis/home/msid/thesis/octnet/distro/install/lib/cunn.so'
        no file './cunn.so'
        no file '/usr/local/lib/lua/5.1/cunn.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'error'
        ...hesis/octnet/distro/install/share/lua/5.1/trepl/init.lua:389: in function 'require'
        train_mn10_r64.lua:5: in main chunk
        [C]: in function 'dofile'
        ...net/distro/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
        [C]: at 0x00406670

I don't know LUA but from what I understand, this error is coming either when it's loading a gpu model on a cpu machine or from the require('cunn') statement. I also see some :add( cudnn.xxxx) statements which require gpu version ? I guess my request is, can you make a cpu-only version of this code and a gpu version ? Thanks in advance !

Can't run through the example.

Hi, thank you for the source code!

The "build_all.sh" was successed. But when I tried the example00, I got errors.

When I use python3.5, I got:
Traceback (most recent call last):
File "create_data.py", line 16, in
import pyoctnet
ImportError: dynamic module does not define module export function (PyInit_pyoctnet)

And when I use python2.7, I got :
Traceback (most recent call last):
File "create_data.py", line 16, in
import pyoctnet
File "init.pxd", line 918, in init pyoctnet
ValueError: numpy.ufunc size changed, may indicate binary incompatibility. Expected 216 from C header, got 192 from PyObject

Is it because the numpy version? Do you know what is the problem?

Accuracy when running code in train_mn10_r64.lua

Hi,

Recently I installed torch and ran the example code from train_mn10_r64.lua. There are 20 epochs and initial learning rate is 0.001 with batch size of 32 using Adam optimizer, everything is as default.
However, the test accuracy is only 0.457, as shown below:
[INFO] loading data took 0.005721[s] - n_batches 32
[INFO] net/crtrn fwd took 0.484423[s]
[INFO] test batch 29/29
[INFO] loading data took 0.004988[s] - n_batches 12
[INFO] net/crtrn fwd took 0.205677[s]
test_epoch=20, avg_f=0.457447

How can I achieve the accuracy as displayed in the octnet paper?

Thanks!

Bad Argument to octree_resize_gpu

After calling
input, target = data_loader:getBatch()
I am trying to resize the input variable.

    local inputSz = input:size()
    inputSz[1] = inputSz[1]*2
    input:resize(inputSz)

The resulting error is this:

/home/master/torch/distro/install/bin/luajit: /home/master/octnet/th/oc/octree.lua:472: bad argument #1 to 'octree_resize_gpu' (cannot convert 'void *' to 'int')
stack traceback:
        [C]: in function 'octree_resize_gpu'
        /home/master/octnet/th/oc/octree.lua:472: in function 'resize'

From what I can see in dataloader.lua, it seems like I'm using it correctly, so I'm not sure what the problem is.

Thanks

Visualization Tools

Hi,

Could you please introduce what tools do you use for Octree visualization?
Thanks.

Segmentation

Is there any implementation of the segmentation module?

Error in Example 00_create_data (after successfully running example 01)

Hello,

I'm getting an error when I try to run example/00. I was able to successfully run example/01_classification_modelnet so I believe its related to some of the dense portions of the code (which is what I'm interested).

The error I get is:
octnet/example/00_create_data$ python2 create_data.py

Traceback (most recent call last):
File "create_data.py", line 33, in
oc_from_dense1 = pyoctnet.Octree.create_from_dense(dense, val_range, n_threads=n_threads)
File "pyoctnet.pyx", line 654, in pyoctnet.Octree.create_from_dense (pyoctnet.cpp:8805)
def create_from_dense(cls, float[:,:,:,::1] dense, bool fit=False, int fit_multiply=1, bool pack=False, int n_threads=1):
ValueError: Buffer has wrong number of dimensions (expected 4, got 3)

Modifying line 27 to add a 4th dimension with:
dense = np.zeros((vx_res,vx_res,vx_res,1), dtype=np.float32)

Leads to the following error:

Traceback (most recent call last):
File "create_data.py", line 33, in
oc_from_dense1 = pyoctnet.Octree.create_from_dense(dense, val_range, n_threads=n_threads)
File "pyoctnet.pyx", line 654, in pyoctnet.Octree.create_from_dense (pyoctnet.cpp:8807)
def create_from_dense(cls, float[:,:,:,::1] dense, bool fit=False, int fit_multiply=1, bool pack=False, int n_threads=1):
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Issue with resolution and batch size

Increasing resolution obviously requires more memory. Using example 01 at 128^3 requires more memory than my GPU has. To try and reduce the memory footprint, I tried to reduce the batch size.

Testing at 64^3 shows that increasing the batch size causes out of memory errors, so reducing it should help.

However, setting the batch size to 16 causes an error "mismatch between the batch size of input (128) and that of target (16)". The first number varies with the batch size (size=12 is 96, ect). Unfortunately, tracing the callstack back out I see no place that the number would come from.

/home/tetragramm/torch/install/share/lua/5.1/nn/THNN.lua:110: bad argument #2 to 'v' (mismatch between the batch size of input (96) and that of target (12) at /home/tetragramm/torch/extra/cunn/lib/THCUNN/generic/ClassNLLCriterion.cu:39)
stack traceback:
	[C]: in function 'v'
	/home/tetragramm/torch/install/share/lua/5.1/nn/THNN.lua:110: in function 'ClassNLLCriterion_updateOutput'
	...amm/torch/install/share/lua/5.1/nn/ClassNLLCriterion.lua:44: in function 'updateOutput'
	...torch/install/share/lua/5.1/nn/CrossEntropyCriterion.lua:20: in function 'forward'
	../common.lua:170: in function 'opfunc'
	/home/tetragramm/torch/install/share/lua/5.1/optim/adam.lua:37: in function 'optimizer'
	../common.lua:180: in function 'train_epoch'
	../common.lua:249: in function 'worker'
	classification_common.lua:97: in function 'classification_worker'
	train_mn10_r64.lua:66: in main chunk
	[C]: in function 'dofile'

How to read octree in python

Hey,

I want to read octree using python since octree is generated using python itself,
pyoctnet.Octree.create_from_off
Could you please let me know whether there are any in-built functionalities for this(may be using pyoctnet or something else)

Or Do I need to read octree through Lua itself?

Also I am curious to know, whether you used 'oc' as package? If so what is the location of it? I am not able to find it.(sorry I don't have much idea on Lua)

Please help!!

Thanks,
Basavaraj

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.