Code Monkey home page Code Monkey logo

pet-neus's Introduction

PET-NeuS: Positional Encoding Tri-Planes for Neural Surfaces

demo

PET-NeuS: Positional Encoding Tri-Planes for Neural Surfaces

Yiqun Wang, Ivan Skorokhodov, Peter Wonka

To appear in CVPR 2023

Paper (arXiv)

Abstract

A signed distance function (SDF) parametrized by an MLP is a common ingredient of neural surface reconstruction. We build on the successful recent method NeuS to extend it by three new components. The first component is to borrow the tri-plane representation from EG3D and represent signed distance fields as a mixture of tri-planes and MLPs instead of representing it with MLPs only. Using tri-planes leads to a more expressive data structure but will also introduce noise in the reconstructed surface. The second component is to use a new type of positional encoding with learnable weights to combat noise in the reconstruction process. We divide the features in the tri-plane into multiple frequency scales and modulate them with sin and cos functions of different frequencies. The third component is to use learnable convolution operations on the tri-plane features using self-attention convolution to produce features with different frequency bands. The experiments show that PET-NeuS achieves high-fidelity surface reconstruction on standard datasets. Following previous work and using the Chamfer metric as the most important way to measure surface reconstruction quality, we are able to improve upon the NeuS baseline by 57% on Nerf-synthetic (0.84 compared to 1.97) and by 15.5% on DTU (0.71 compared to 0.84). The qualitative evaluation reveals how our method can better control the interference of high-frequency noise.

demo

demo

Usage

Environment

pip install - r requirements.txt

Training and Evaluation

bash run.sh

Citation

Consider Citing the following paper if this program benefits your project

@article{wang2023petneus,
  title={PET-NeuS: Positional Encoding Triplanes for Neural Surfaces},
  author={Wang, Yiqun and Skorokhodov, Ivan and Wonka, Peter}
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year={2023}
}

pet-neus's People

Contributors

yiqun-wang 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

pet-neus's Issues

CUDA out of memory

Thank you for your impressive work! However, I trained it on a NVIDIA RTX 3090 with a batch size of 2 in womask_pet.conf, and is still resulting in out-of-memory issues. Is there anything wrong with my configuration parameters? How much memory does the model take with the default batch size of 2048?

Exception has occurred: RuntimeError
CUDA out of memory. Tried to allocate 1.50 GiB (GPU 0; 23.70 GiB total capacity; 20.47 GiB already allocated; 587.56 MiB free; 21.03 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

What is the box_warp here means?

Thanks for your great excellent work.I have a little question about this params in the code box_warp,It seems that you use this params to scale the coordinates,in your conf,you set this params to be 3,It is in the triplane_pet.py:

def sample_from_planes(plane_axes, plane_features, coordinates, mode='bilinear', padding_mode='zeros', box_warp=None):
    assert padding_mode == 'zeros'
    N, n_planes, C, H, W = plane_features.shape
    _, M, _ = coordinates.shape
    plane_features = plane_features.view(N*n_planes, C, H, W)

    coordinates = (2/box_warp) * coordinates #why?

    projected_coordinates = project_onto_planes(plane_axes, coordinates).unsqueeze(1)
    output_features = grid_sample.grid_sample_2d(plane_features, projected_coordinates.float()).permute(0, 3, 2, 1).reshape(N, n_planes, M, C) 

    return output_features #[1, 3, num_points, channels]

I want to know why have to do like that,thank you!

TypeError: 'tuple' object is not callable

I get the following error when running bash run.sh:

Setting up PyTorch plugin "gridsample_grad2"... /home/dan/miniconda3/envs/petneus/lib/python3.8/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3483.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
/home/dan/miniconda3/envs/petneus/lib/python3.8/site-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead.
  warnings.warn(
/home/dan/miniconda3/envs/petneus/lib/python3.8/site-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing `weights=VGG16_Weights.IMAGENET1K_V1`. You can also use `weights=VGG16_Weights.DEFAULT` to get the most up-to-date weights.
  warnings.warn(msg)

  0%|          | 0/100000 [00:00<?, ?it/s]
  0%|          | 0/100000 [00:00<?, ?it/s]
Done.
Hello Wooden
Load data: Begin
Load data: End
Setting up [LPIPS] perceptual loss: trunk [vgg], v[0.1], spatial [off]
Loading model from: /home/dan/miniconda3/envs/petneus/lib/python3.8/site-packages/lpips/weights/v0.1/vgg.pth
Traceback (most recent call last):
  File "exp_runner_pet.py", line 497, in <module>
    runner.train()
  File "exp_runner_pet.py", line 167, in train
    render_out = self.renderer.render(rays_o, rays_d, near, far,
  File "/mnt/d/apps/PET-NeuS/models/renderer_pet.py", line 364, in render
    gradient = self.sdf_network.gradient(pts.reshape(-1, 3)).squeeze().detach()
  File "/mnt/d/apps/PET-NeuS/models/triplane_pet.py", line 159, in gradient
    gradients = torch.autograd.grad(
  File "/home/dan/miniconda3/envs/petneus/lib/python3.8/site-packages/torch/autograd/__init__.py", line 303, in grad
    return Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass
  File "/home/dan/miniconda3/envs/petneus/lib/python3.8/site-packages/torch/autograd/function.py", line 274, in apply
    return user_fn(self, *args)
  File "/mnt/d/apps/PET-NeuS/third_party/ops/grid_sample.py", line 59, in backward
    grad_input, grad_grid = _GridSample2dBackward.apply(grad_output, input, grid, ctx.padding_mode, ctx.align_corners)
  File "/home/dan/miniconda3/envs/petneus/lib/python3.8/site-packages/torch/autograd/function.py", line 506, in apply
    return super().apply(*args, **kwargs)  # type: ignore[misc]
  File "/mnt/d/apps/PET-NeuS/third_party/ops/grid_sample.py", line 68, in forward
    grad_input, grad_grid = op(grad_output, input, grid, 0, padding_mode, align_corners, output_mask)
TypeError: 'tuple' object is not callable

Configurations used in your paper

Thanks for sharing your work in public.

Regarding to the configuration attached in this GitHub, I thought this version might be slightly different than what you used for representing numerical performance.
When I computed chamfer distance for the dtu_scan106, I obtained 0.57 with the official configuration.
(In this paper, you achieved 0.51 chamfer distance in the dtu_scan106)

Also, it took at least 24 hours for training. My computation resource is RTX A6000, EPIC 24-core CPUs and 256 GB Memory.
(In this setup, I followed the configuration in the official GitHub.)
This configuration sets as 100,000 training steps by default.

However, in accordance with your paper, you took 9 hours for training DTU dataset via the V100 resource.
I think there exists blurry explanation of your configuration for achieving numerical results you reported.

For this reason, could you share all configurations you used in this paper?
At least, I'd like to have the configuration for all scenes in the DTU dataset.

Best regards,

-Mingyu Kim-

Problems with running custom datasets

This is a very great job, but when I run the custom dataset, the cameras.npz file is generated according to the neus format, but the effect of reconstructing several scenes is not good. Do you know why
image
image
Uploading image.png…
And the picture I used for training looks like this
IMG20220607103013
IMG_4565
If you have a good solution, I will be very grateful for your help

environment problem

could you tell the cuda version please.
and the requiements isn't complete,it's lack of "tensorboard requests"

How to get ckpt_xxxxxxx.pth

Hello,
Thank you for this great work. Can you tell me where to get the file ckpt and how to get it? ckpt_name='ckpt_100000.pth'

Compile error on "gridsample_grad2"

Hi, thanks for your great work! I try to run the code on a linux server and came across compile error when compiling the CUDA source. The complete error log can be found here, some critical errors are:

/root/.cache/torch_extensions/gridsample_grad2/f6f3395827c77b6f68bed38af0c94ab3-tesla-v100-sxm2-32gb/gridsample_cuda.cu(560): error: too many arguments in function call

/root/.cache/torch_extensions/gridsample_grad2/f6f3395827c77b6f68bed38af0c94ab3-tesla-v100-sxm2-32gb/gridsample_cuda.cu(189): error: no instance of function template "at::native::safe_add_2d" matches the argument list
            argument types are: (double *, int, int, int, int, int, int, double, int, const int)
          detected during instantiation of "void at::native::<unnamed>::grid_sampler_2d_grad2_kernel(index_t, at::cuda::detail::TensorInfo<scalar_t, index_t>, at::cuda::detail::TensorInfo<scalar_t, index_t>, at::cuda::detail::TensorInfo<scalar_t, index_t>, at::cuda::detail::TensorInfo<scalar_t, index_t>, at::cuda::detail::TensorInfo<scalar_t, index_t>, at::cuda::detail::TensorInfo<scalar_t, index_t>, at::cuda::detail::TensorInfo<scalar_t, index_t>, at::cuda::detail::TensorInfo<scalar_t, index_t>, at::native::detail::GridSamplerPadding, __nv_bool, index_t) [with scalar_t=double, index_t=int]" 
(560): here

/root/.cache/torch_extensions/gridsample_grad2/f6f3395827c77b6f68bed38af0c94ab3-tesla-v100-sxm2-32gb/gridsample_cuda.cu(474): error: no instance of function template "at::native::safe_add_3d" matches the argument list
            argument types are: (double *, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, double, int64_t, const int64_t)
          detected during instantiation of "void at::native::<unnamed>::grid_sampler_3d_grad2_kernel(index_t, at::cuda::detail::TensorInfo<scalar_t, index_t>, at::cuda::detail::TensorInfo<scalar_t, index_t>, at::cuda::detail::TensorInfo<scalar_t, index_t>, at::cuda::detail::TensorInfo<scalar_t, index_t>, at::cuda::detail::TensorInfo<scalar_t, index_t>, at::cuda::detail::TensorInfo<scalar_t, index_t>, at::cuda::detail::TensorInfo<scalar_t, index_t>, at::cuda::detail::TensorInfo<scalar_t, index_t>, at::native::detail::GridSamplerPadding, __nv_bool, index_t) [with scalar_t=double, index_t=int64_t]" 
(627): here

It seems the complier cannot found the correct function definition of safe_add_2d, safe_add_3d and AT_DISPATCH_FLOATING_TYPES_AND_HALF.

My environment is torch 1.8.0 with CUDA 11.1, Ubuntu 20.04.

Do you have any idea what maybe the problem? Thanks!

Setting up PyTorch plugin "gridsample_grad2"... Failed!

Hi I meet this trouble, the problem is list below:
Setting up PyTorch plugin "gridsample_grad2"... Failed!
Traceback (most recent call last):
File "/home/anaconda3/envs/Neus/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1673, in _run_ninja_build
env=env)
File "/home/anaconda3/envs/Neus/lib/python3.7/subprocess.py", line 512, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "./exp_runner_pet.py", line 19, in
from models.triplane_pet import TriPlaneGenerator
File "/mnt/hdd2/code/PET-NeuS/models/triplane_pet.py", line 7, in
from third_party.ops import grid_sample
File "/mnt/hdd2/code/PET-NeuS/third_party/ops/grid_sample.py", line 26, in
init()
File "/mnt/hdd2/code/PET-NeuS/third_party/ops/grid_sample.py", line 22, in init
extra_cuda_cflags=['--use_fast_math'],
File "/mnt/hdd2/code/PET-NeuS/third_party/custom_ops.py", line 139, in get_plugin
verbose=verbose_build, sources=cached_sources, **build_kwargs)
File "/home/anaconda3/envs/Neus/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1091, in load
keep_intermediates=keep_intermediates)
File "/home/anaconda3/envs/Neus/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1302, in jit_compile
is_standalone=is_standalone)
File "/home/anaconda3/envs/Neus/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1407, in write_ninja_file_and_build_library
error_prefix=f"Error building extension '{name}'")
File "/home/anaconda3/envs/Neus/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1683, in run_ninja_build
raise RuntimeError(message) from e
RuntimeError: Error building extension 'gridsample_grad2': [1/2] /usr/local/cuda-11.2/bin/nvcc --generate-dependencies-with-compile --dependency-output gridsample_cuda.cuda.o.d -DTORCH_EXTENSION_NAME=gridsample_grad2 -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="gcc" -DPYBIND11_STDLIB="libstdcpp" -DPYBIND11_BUILD_ABI="cxxabi1011" -isystem /home/anaconda3/envs/Neus/lib/python3.7/site-packages/torch/include -isystem /home/anaconda3/envs/Neus/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -isystem /home/anaconda3/envs/Neus/lib/python3.7/site-packages/torch/include/TH -isystem /home/anaconda3/envs/Neus/lib/python3.7/site-packages/torch/include/THC -isystem /usr/local/cuda-11.2/include -isystem /home/anaconda3/envs/Neus/include/python3.7m -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS -D__CUDA_NO_HALF_CONVERSIONS
-D__CUDA_NO_BFLOAT16_CONVERSIONS
-D__CUDA_NO_HALF2_OPERATORS

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.