This repository contains a Torch module for volumetric nearest neighbor upsampling based on kmul00/torch-vol. In the original repository, the nearest neighbor upsampling did not allow distinct scaling factors for all three dimensions of the processed volumes; the module in this repository changes that.
If you use this tool, please consider citing the following thesis:
@inproceedings{Stutz2018CVPR,
title = {Learning 3D Shape Completion from Laser Scan Data with Weak Supervision},
author = {David Stutz and Andreas Geiger},
booktitle = {IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
publisher = {IEEE Computer Society},
year = {2018}
}
Also check the corresponding project page.
Installation instructions roughly follow the instructions given in kmul00/torch-vol:
-
Install Torch, for example using torch/distro.
-
Install the following requirements: nnx and cunnx. Clone the repositories but do not install them yet. Note that torch/distro might include
nnx
already. -
Copy
VolumetricUpSamplingNearest.lua
from this repository into thennx
repository. -
Adapt
init.lua
(in thennx
repository) to include a linerequire('nnx.VolumetricUpSamplingNearest')
. -
Copy
generic/VolumetricUpSamplingNearest.c
intonnx/generic
. -
Adapt
init.c
(innnx
) to include the following lines:// Before function luaopen_libnnx #include "generic/VolumetricUpSamplingNearest.c" #include "THGenerateFloatTypes.h" // ... // In function luaopen_libnnx nn_FloatVolumetricUpSamplingNearest_init(L); nn_DoubleVolumetricUpSamplingNearest_init(L);
-
Use
luarocks make nnx-0.1-1.rockspec
to buildnnx
including the volumetric upsampling module. -
After cloning
cunnx
, copycuda/VolumetricUpSamplingNearest.cu
tocunnx
. -
Adapt
init.cu
:// Before luaopen_libcunnx. #include "VolumetricUpSamplingNearest.cu" // In luaopen_libcunnx. cunn_VolumetricUpSamplingNearest_init(L); // NOTE: cunn_ AND NOT cunnx_!
-
Build
cunnx
usingluarocks make rocks/cunnx-scm-1.rockspec
. -
Run
th test.lua
to see if everything works correctly.
Usage is very simple and illustrated in test.lua
:
local model = nn.Sequential()
model:add(nn.VolumetricUpSamplingNearest(2, 3, 4))
model:add(nn.VolumetricUpSamplingNearest(2, 3, 4))
local input = torch.Tensor(8, 2, 10, 10, 10):fill(1)
local goutput = torch.Tensor(8, 2, 40, 90, 160):fill(1)
local output = model:forward(input)
print(#output)
local ginput = model:backward(input, goutput)
print(#ginput)
Here, VolumetricUpSamplingNearest
expects three arguments, the upsampling factors
in the first, second and third dimensions.
Original license:
Copyright (c) [2015] [Koustav Mullick]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Changes:
Copyright (c) 2017 David Stutz
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.