DIVeR: Deterministic Integration for Volume Rendering

Related tags

Deep Learning diver
Overview

DIVeR: Deterministic Integration for Volume Rendering

This repo contains the training and evaluation code for DIVeR.

Setup

  • python 3.8
  • pytorch 1.9.0
  • pytorch-lightning 1.2.10
  • torchvision 0.2.2
  • torch-scatter 2.0.8

Dataset

Pre-trained models

Both our real-time and offline models can be found in here.

Usage

Edit configs/config.py to configure a training and setup dataset path.

To reproduce the results of the paper, replace config.py with other configuration files under the same folder.

The 'implicit' training stage takes around 40GB GPU memory and the 'implicit-explicit' stage takes around 20GB GPU memory. Decreasing the voxel grid size by a factor of 2 results in models that require around 10GB GPU memory, which causes acceptable deduction on rendering quality.

Training

To train an explicit or implicit model:

python train.py --experiment_name=EXPERIMENT_NAME \
				--device=GPU_DEVICE\
				--resume=True # if want to resume a training

After training an implicit model, the explicit model can be trained:

python train.py --experiment_name=EXPERIMENT_NAME \
				--ft=CHECKPOINT_PATH_TO_IMPLICIT_MODEL_CHECKPOINT\
				--device=GPU_DEVICE\
				--resume=True

Post processing

After the coarse model training and the fine 'implicit-explicit' model training, we perform voxel culling:

python prune.py --checkpoint_path=PATH_TO_MODEL_CHECKPOINT_FOLDER\
				--coarse_size=COARSE_IMAGE_SIZE\
				--fine_size=FINE_IMAGE_SIZE\
				--fine_ray=1 # to get rays that pass through non-empty space, 0 otherwise\
				--batch=BATCH_SIZE\
				--device=GPU_DEVICE

which stores the max-scattered 3D alpha map under model checkpoint folder as alpha_map.pt . The rays that pass through non-empty space is also stored under model checkpoint folder. For Nerf-synthetic dataset, we directly store the rays in fine_rays.npz; for Tanks&Temples and BlendedMVS, we store the mask for each pixel under folder masks which indicates the pixels (rays) to be sampled.

To convert the checkpoint file in training to pytorch model weight or serialized weight file for real-time rendering:

python convert.py --checkpoint_path=PATH_TO_MODEL_CHECKPOINT_FILE\
				  --serialize=1 # if want to build serialized weight, 0 otherwise

The converted files will be stored under the same folder as the checkpoint file, where the pytorch model weight file is named as weight.pth, and the serialized weight file is named as serialized.pth

Evaluation

To extract the offline rendered images:

python eval.py --checkpoint_path=PATH_TO_MODEL_CHECKPOINT_FILE\
			   --output_path=PATH_TO_OUTPUT_IMAGES_FOLDER\
			   --batch=BATCH_SIZE\
			   --device=GPU_DEVICE

To extract the real-time rendered images and test the mean FPS on the test sequence:

pyrhon eval_rt.py --checkpoint_path=PATH_TO_SERIALIZED_WEIGHT_FILE
				  --output_path=PATH_TO_OUPUT_IMAGES_FOLDER\
				  --decoder={32,64} # diver32, diver64\ 
				  --device=GPU_DEVICE

Resources

Citation

@misc{wu2021diver,
      title={DIVeR: Real-time and Accurate Neural Radiance Fields with Deterministic Integration for Volume Rendering}, 
      author={Liwen Wu and Jae Yong Lee and Anand Bhattad and Yuxiong Wang and David Forsyth},
      year={2021},
      eprint={2111.10427},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}
Comments
  • Understanding the pre-multiply first linear

    Understanding the pre-multiply first linear

    Hi, thank you very much for your great work! Currently, I am using a modified diver model for one of my research. In this model, the size of the first layer is different (bigger), so I would like to know in detail how the pre-multiplication logic works, to see if I can premultiply my first layer with the features.

    To the best of my knowledge, we keep the layer bias 0 "new_weight['weightin'][:,0]," and then perform the premultiplication to the features. Why we perform the transpose? "features = (features@new_weight['weightin'][:,1:].T).contiguous()", in this case, the shapes of the weights are 32x32, what happens if i change the size of my layers?

    params = torch.cat([
                    new_weight['weightin'][:,0],
                    new_weight['weight0'].T.reshape(-1),
                    new_weight['weight1'].reshape(-1),
                    w2.T.reshape(-1),
                    new_weight['weight3'].T.reshape(-1),
                    torch.zeros(28),
    ],0).contiguous() 
    
    # store feature vectors in an 1d array
    voxels = new_weight['voxels'].coalesce()
    N = voxels.shape[0]-1
    idxs = voxels.indices()
    features = voxels.values()
    
    # pre-multiply first linear layer to feature vector for diver32 model
    if voxel_dim == 32:
        features = (features@new_weight['weightin'][:,1:].T).contiguous()
    

    Thanks :)

    opened by doramasma 2
  • Calculate gradient

    Calculate gradient

    Hi! First of all, thank you very much for your fantastic work and code!
    I am trying to optimize the c2w matrix(rotation and translation {R, t}). Now after loss.backward(), the gradient of R can be calculated, R can be optimized, but the gradient of t is calculated as None. Do you have any suggestions for this?

    opened by Esme-lxy 2
  • Integration of trilinear interpolation

    Integration of trilinear interpolation

    Hi!

    First of all, congrats for your work! I really enjoyed reading the paper ang going through the code (which is quite understandable). I have a question about how you integrate the trilinear interpolation of the features for each voxel. In the paper, you obtain the following equation: imagen

    I do not see how you finally solve the integral and how you implemented. I undestand the implementation is the following one on integrator.py:

    `

    A = P.sum(0).prod(0)/12+(P.prod(1).sum(0))/6
    X = F[1] - F[0]
    X = X[0] - X[1]
    X = X[0] - X[1]
    feature = A[:,None]*X
    
    P_roll = P[:,[1,2,0]]
    # 3xBxM
    B = (P*P_roll).sum(0)/3+(P*P_roll[[1,0]]).sum(0)/6
    # 3xBxMxC
    Y = F[0,0,0,None]-F[[0,0,1],[1,1,0],0]\
       -F[[0,1,0],0,[1,0,1]]+F[[0,1,1],[1,1,0],[1,0,1]]
    feature = feature + torch.einsum('dk,dkc->kc',B,Y)
    
    # 3xBxM
    C = P.sum(0)/2
    # 3xBxMxC
    Z = F[[0,0,1],[0,1,0],[1,0,0]]-F[0,0,0,None]
    feature = feature + torch.einsum('dk,dkc->kc',C,Z)
    feature = feature + F[0,0,0]
    

    `

    What is the actual formula you are applying here? Do you have some derivation of the integral and this implementation?

    Thanks in advance!

    opened by Frivas97 2
  • Training procedure

    Training procedure

    Hi @lwwu2,

    First of all, thanks so much for the great work and for making the code available!

    I was trying to train a DIVeR on the drums sequence from nerf-synthetic dataset. The readme for the training is unclear to me and I got some very weird results. Below is my way of training:

    1. Train an implicit model in the coarse level (by replacing configs/config.py with configs/nerf_synthetic_coarse.py), and run python train.py --experiment_name=drums --gpus=1 --resume
    2. Prune this trained coarse model via python prune.py --checkpoint_path=logs/drums/version_3/checkpoints
    3. Continue training on the fine level (by replacing configs/config.py with configs/nerf_synthetic_fine.py), and run python train.py --experiment_name=drums --gpus=1 --resume.

    Right after step 3, I obtain something very strange already, as shown here: https://imgur.com/a/mz6ILXq. I wonder which step I made a mistake? Also, could you please make the training step more clear so we know how to really reproduce the results shown in the paper?

    Thanks so much in advance!

    Best, Songyou

    opened by pengsongyou 1
  • Depth map

    Depth map

    Hi, thank you very much for your great work! I can get the correct rgb image with your code, but the depth map is not very accurate. I am using the following code to render the depth map.

    color, sigma, mask, ts = model(ray_o, ray_d)
    depth = (ts*mask*weight).sum(1)
    

    The rendered result(left) and ground truth(right) of the depth map is as follows. 1 The rendered result is more like a grayscale image but not depth map, Do you have any suggestions for this?

    opened by kaiaa7 4
  • Own Dataset

    Own Dataset

    Hi, congratulations on your paper. The results look great and I can't wait to try it on my own data! Would it be possible for you to add instructions as to what is required?

    opened by sixftninja 6
Owner
null
Hand Gesture Volume Control is AIML based project which uses image processing to control the volume of your Computer.

Hand Gesture Volume Control Modules There are basically three modules Handtracking Program Handtracking Module Volume Control Program Handtracking Pro

VITTAL 1 Jan 12, 2022
Volsdf - Volume Rendering of Neural Implicit Surfaces

Volume Rendering of Neural Implicit Surfaces Project Page | Paper | Data This re

Lior Yariv 221 Jan 7, 2023
MINIROCKET: A Very Fast (Almost) Deterministic Transform for Time Series Classification

MINIROCKET: A Very Fast (Almost) Deterministic Transform for Time Series Classification

null 187 Dec 26, 2022
A Pytorch implementation of the multi agent deep deterministic policy gradients (MADDPG) algorithm

Multi-Agent-Deep-Deterministic-Policy-Gradients A Pytorch implementation of the multi agent deep deterministic policy gradients(MADDPG) algorithm This

Phil Tabor 159 Dec 28, 2022
Code for Deterministic Neural Networks with Appropriate Inductive Biases Capture Epistemic and Aleatoric Uncertainty

Deep Deterministic Uncertainty This repository contains the code for Deterministic Neural Networks with Appropriate Inductive Biases Capture Epistemic

Jishnu Mukhoti 69 Nov 28, 2022
This tool converts a Nondeterministic Finite Automata (NFA) into a Deterministic Finite Automata (DFA)

This tool converts a Nondeterministic Finite Automata (NFA) into a Deterministic Finite Automata (DFA)

Quinn Herden 1 Feb 4, 2022
Official pytorch implementation for Learning to Listen: Modeling Non-Deterministic Dyadic Facial Motion (CVPR 2022)

Learning to Listen: Modeling Non-Deterministic Dyadic Facial Motion This repository contains a pytorch implementation of "Learning to Listen: Modeling

null 50 Dec 17, 2022
CFNet: Cascade and Fused Cost Volume for Robust Stereo Matching(CVPR2021)

CFNet(CVPR 2021) This is the implementation of the paper CFNet: Cascade and Fused Cost Volume for Robust Stereo Matching, CVPR 2021, Zhelun Shen, Yuch

null 106 Dec 28, 2022
Using this you can control your PC/Laptop volume by Hand Gestures (pinch-in, pinch-out) created with Python.

Hand Gesture Volume Controller Using this you can control your PC/Laptop volume by Hand Gestures (pinch-in, pinch-out). Code Firstly I have created a

Tejas Prajapati 16 Sep 11, 2021
Hand Gesture Volume Control | Open CV | Computer Vision

Gesture Volume Control Hand Gesture Volume Control | Open CV | Computer Vision Use gesture control to change the volume of a computer. First we look i

Jhenil Parihar 3 Jun 15, 2022
Official PyTorch Implementation of paper "Deep 3D Mask Volume for View Synthesis of Dynamic Scenes", ICCV 2021.

Deep 3D Mask Volume for View Synthesis of Dynamic Scenes Official PyTorch Implementation of paper "Deep 3D Mask Volume for View Synthesis of Dynamic S

Ken Lin 17 Oct 12, 2022
Gesture Volume Control Using OpenCV and MediaPipe

This Project Uses OpenCV and MediaPipe Hand solutions to identify hands and Change system volume by taking thumb and index finger positions

Pratham Bhatnagar 6 Sep 12, 2022
Fast algorithms to compute an approximation of the minimal volume oriented bounding box of a point cloud in 3D.

ApproxMVBB Status Build UnitTests Homepage Fast algorithms to compute an approximation of the minimal volume oriented bounding box of a point cloud in

Gabriel Nützi 390 Dec 31, 2022
Python code to fuse multiple RGB-D images into a TSDF voxel volume.

Volumetric TSDF Fusion of RGB-D Images in Python This is a lightweight python script that fuses multiple registered color and depth images into a proj

Andy Zeng 845 Jan 3, 2023
Gesture Volume Control v.2

Gesture volume control v.2 In this project I am going to learn how to use Gesture Control to change the volume of a computer. I first look into hand t

Pavel Dat 23 Dec 26, 2022
Code for "Layered Neural Rendering for Retiming People in Video."

Layered Neural Rendering in PyTorch This repository contains training code for the examples in the SIGGRAPH Asia 2020 paper "Layered Neural Rendering

Google 154 Dec 16, 2022
NeRViS: Neural Re-rendering for Full-frame Video Stabilization

Neural Re-rendering for Full-frame Video Stabilization

Yu-Lun Liu 9 Jun 17, 2022
Neural Re-rendering for Full-frame Video Stabilization

NeRViS: Neural Re-rendering for Full-frame Video Stabilization Project Page | Video | Paper | Google Colab Setup Setup environment for [Yu and Ramamoo

Yu-Lun Liu 9 Jun 17, 2022