GithubHelp home page GithubHelp logo

yenchenlin / nerf-pytorch Goto Github PK

View Code? Open in Web Editor NEW
5.2K 54.0 1.0K 3.99 MB

A PyTorch implementation of NeRF (Neural Radiance Fields) that reproduces the results.

License: MIT License

Shell 0.36% Python 99.64%

nerf-pytorch's Introduction

NeRF-pytorch

NeRF (Neural Radiance Fields) is a method that achieves state-of-the-art results for synthesizing novel views of complex scenes. Here are some videos generated by this repository (pre-trained models are provided below):

This project is a faithful PyTorch implementation of NeRF that reproduces the results while running 1.3 times faster. The code is based on authors' Tensorflow implementation here, and has been tested to match it numerically.

Installation

git clone https://github.com/yenchenlin/nerf-pytorch.git
cd nerf-pytorch
pip install -r requirements.txt
Dependencies (click to expand)

Dependencies

  • PyTorch 1.4
  • matplotlib
  • numpy
  • imageio
  • imageio-ffmpeg
  • configargparse

The LLFF data loader requires ImageMagick.

You will also need the LLFF code (and COLMAP) set up to compute poses if you want to run on your own real data.

How To Run?

Quick Start

Download data for two example datasets: lego and fern

bash download_example_data.sh

To train a low-res lego NeRF:

python run_nerf.py --config configs/lego.txt

After training for 100k iterations (~4 hours on a single 2080 Ti), you can find the following video at logs/lego_test/lego_test_spiral_100000_rgb.mp4.


To train a low-res fern NeRF:

python run_nerf.py --config configs/fern.txt

After training for 200k iterations (~8 hours on a single 2080 Ti), you can find the following video at logs/fern_test/fern_test_spiral_200000_rgb.mp4 and logs/fern_test/fern_test_spiral_200000_disp.mp4


More Datasets

To play with other scenes presented in the paper, download the data here. Place the downloaded dataset according to the following directory structure:

├── configs                                                                                                       
│   ├── ...                                                                                     
│                                                                                               
├── data                                                                                                                                                                                                       
│   ├── nerf_llff_data                                                                                                  
│   │   └── fern                                                                                                                             
│   │   └── flower  # downloaded llff dataset                                                                                  
│   │   └── horns   # downloaded llff dataset
|   |   └── ...
|   ├── nerf_synthetic
|   |   └── lego
|   |   └── ship    # downloaded synthetic dataset
|   |   └── ...

To train NeRF on different datasets:

python run_nerf.py --config configs/{DATASET}.txt

replace {DATASET} with trex | horns | flower | fortress | lego | etc.


To test NeRF trained on different datasets:

python run_nerf.py --config configs/{DATASET}.txt --render_only

replace {DATASET} with trex | horns | flower | fortress | lego | etc.

Pre-trained Models

You can download the pre-trained models here. Place the downloaded directory in ./logs in order to test it later. See the following directory structure for an example:

├── logs 
│   ├── fern_test
│   ├── flower_test  # downloaded logs
│   ├── trex_test    # downloaded logs

Reproducibility

Tests that ensure the results of all functions and training loop match the official implentation are contained in a different branch reproduce. One can check it out and run the tests:

git checkout reproduce
py.test

Method

NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis
Ben Mildenhall*1, Pratul P. Srinivasan*1, Matthew Tancik*1, Jonathan T. Barron2, Ravi Ramamoorthi3, Ren Ng1
1UC Berkeley, 2Google Research, 3UC San Diego
*denotes equal contribution

A neural radiance field is a simple fully connected network (weights are ~5MB) trained to reproduce input views of a single scene using a rendering loss. The network directly maps from spatial location and viewing direction (5D input) to color and opacity (4D output), acting as the "volume" so we can use volume rendering to differentiably render new views

Citation

Kudos to the authors for their amazing results:

@misc{mildenhall2020nerf,
    title={NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis},
    author={Ben Mildenhall and Pratul P. Srinivasan and Matthew Tancik and Jonathan T. Barron and Ravi Ramamoorthi and Ren Ng},
    year={2020},
    eprint={2003.08934},
    archivePrefix={arXiv},
    primaryClass={cs.CV}
}

However, if you find this implementation or pre-trained models helpful, please consider to cite:

@misc{lin2020nerfpytorch,
  title={NeRF-pytorch},
  author={Yen-Chen, Lin},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished={\url{https://github.com/yenchenlin/nerf-pytorch/}},
  year={2020}
}

nerf-pytorch's People

Contributors

holzers avatar krrish94 avatar msaroufim avatar willbrennan avatar yenchenlin 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nerf-pytorch's Issues

Questions regarding rescaling the scene

Hi, thanks for the project,

I have a couple of questions regarding the lines below, if I understand correctly, bds stores the near and far bounds for each pose. My questions are:

  1. Why the poses are scaled using bd_factor and sc?
  2. Why bd_factor is set to 0.75 and how this affect the results?

sc = 1. if bd_factor is None else 1./(bds.min() * bd_factor)

poses[:,:3,3] *= sc

bds *= sc

device-side assert triggered

Traceback (most recent call last):
File "run_nerf.py", line 858, in
train()
File "run_nerf.py", line 742, in train
**render_kwargs_train)
File "run_nerf.py", line 126, in render
all_ret = batchify_rays(rays, chunk, **kwargs)
File "run_nerf.py", line 59, in batchify_rays
ret = render_rays(rays_flat[i:i+chunk], **kwargs)
File "run_nerf.py", line 401, in render_rays
raw = network_query_fn(pts, viewdirs, run_fn)
File "run_nerf.py", line 204, in
netchunk=args.netchunk)
File "run_nerf.py", line 49, in run_network
outputs_flat = batchify(fn, netchunk)(embedded)
File "run_nerf.py", line 33, in ret
return torch.cat([fn(inputs[i:i+chunk]) for i in range(0, inputs.shape[0], chunk)], 0)
File "run_nerf.py", line 33, in
return torch.cat([fn(inputs[i:i+chunk]) for i in range(0, inputs.shape[0], chunk)], 0)
File "/usr/local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/ovopark/nerf-pytorch-master/run_nerf_helpers.py", line 104, in forward
h = F.relu(h)
File "/usr/local/lib/python3.6/site-packages/torch/nn/functional.py", line 1119, in relu
result = torch.relu(input)
RuntimeError: CUDA error: device-side assert triggered
➜ nerf-pytorch-master

Help obtaining .json files from blender objects

Hello! How can you make new poses and create .json files from new synthetic objects. I have an object I made in Blender and I want to obtain those to complete the dataset.
Thank you and stay safe!

Issue with training low-res lego NeRF

Hi, I followed the instructions to train the low-res lego NeRF.
But at iteration 100,000 I realized the disp_map video saved was an invalid file.
Upon investigating, the disp_map array being saved contained np.nan values.(Also, I switched the video writing from using imageio library to cv2 library.)

This was traced to line 387 in run_nerf.py.
raw = network_query_fn(pts, viewdirs, network_fn)
Some rows of raw[...,3] , representing density, were negative.

Then at line 277, under the function raw2outputs(line 264):
raw2alpha = lambda raw, dists, act_fn=F.relu: 1.-torch.exp(-act_fn(raw)*dists)
evaluates to zero, due to ReLU on negative value.
This leads to the np.nan values appearing in disp_map within the same function block.

So I would like to ask,
Am I doing something wrong here? Or is this an expected behaviour? Please kindly advise

A question of "no attribute" error

Hi, I was trying to replicate the results with your code. But when it comes to the "fine" part, the code render_kwargs_train['network_fine'].state_dict() always leaves me an error like 'NoneType' object has no attribute 'state_dict', I don't know the reason. As I'm a beginner, I sincerely hope you can help me out. Much thanks!

Perfect peformance with lego, but bad with other objects.

Hey, @yenchenlin thanks for your pytorch implementation of nerf!

When I trained with lego in the nerf synthetic dataset, the test result is not bad even with only 20000 iterations.
004
For example, above is a render result of lego.
However, when I tried to train other objects in nerf synthetic dataset, it did not work.
Render result of ship with 30000 iterations training:

000 (1)
Render result of chair with 50000 iterations training (a white image as follows) :
001

Therefore, the result is also not satisfying when I trained on my own 360 degree synthetic inward-facing dataset.
I compared the nerf network in the official tensorflow release and that in this repo. It seems both are 8 layers MLP.
Is there anyone has ideas?

Seems not converge on Lego

Hi, thanks for your great PyTorch implementation!
After running on the lego data, I found the loss is around 0.13 and the output video and test frames are all white or black.

010

Hope for your help! Thank you!

Train on DTU dataset

how to train the nerf on other than LLFF dataset?
how to generate config for other data?

Rendered depth video is black

I try to train a NeRF on the lego bulldozer scene, and although the RGB video comes out as expected, the depth video is just black. I'm using torch==1.8.1 and torchvision==0.9.1 with cuda-10.2. Any idea, what could be going wrong?

TypeError: type torch.cuda.FloatTensor not available. Torch not compiled with CUDA enabled.

detail on traceback:
Traceback (most recent call last):
File "F:\fuxian\nerf-pytorch\run_nerf.py", line 876, in
torch.set_default_tensor_type('torch.cuda.FloatTensor')
File "F:\Program\Anaconda3\lib\site-packages\torch_init_.py", line 321, in set_default_tensor_type
_C._set_default_tensor_type(t)

This error occurs after ' python run_nerf.py --config configs/lego.txt'
How to solve it?

Why no_batching=True when using blender data type?

Hi,

I'm a little confused about the config setting: Why no_batching=True when using blender data type? Are there any special considerations for doing this?

I notice that when no_batching=True, the code will sample rays near the center of the image, and I'm confused about why doing such operation with blender data rather than llff data type?

Thanks

5D input or 6D input ?

In nerf paper, they use a 5D input (x; y; z; θ; φ). In this implementation, the input is 6D, which is inconsistent with nerf paper.

Results of applying NeRF

Hi,
Thank you for the great work.

I applied NeRF to my datasets that was obtained through the ios_logger app.
This is data loaging code.

The following is the result of training 200,000 times.
[Origin Image]
Origin Image

[Result RGB image]
Result RGB image

[Result Depth image]
Result Depth image

As you can see from the images, the result is not good.
The RGB image is very blurry and the depth image did not extract properly.

  1. Have you ever applied data by acquiring it with an iPhone?
  2. Do you know why the result came out like this? Do you know how to slove this problem? What should I do to get proper result from the data I acquired?

Thank you in advance for reading this long post!

What is 'camera_angle_x' and 'rotation' in data ?

Hello, thanks for your excellent implementation.

I am sorry but because I am new to this area. When I open the data file, say transforms_test.json, I find that there are keys named 'camera_angle_x' and 'rotation'.
Could you please explain the two keys in detail? If I guess right, they are parameters about the camera pose. But why 'transform_matrix' is not enough to represent the camera pose? Why do we need 'camera_angle_x' and 'rotation' and how to get them?
Thanks!

please update K in render_path, cause a lot of trouble

Hi,

You added K in run_nerf.py, but you did not update K in render_path() which will cause rendering problem when users set different render factors. Please add that. It takes me two days to find this problem.

Best,

assert triggered!

python run_nerf.py --config configs/fern.txt --render_only
Loaded image data (378, 504, 3, 20) [378. 504. 407.56579161]
Loaded ./data/nerf_llff_data/fern 16.985296178676084 80.00209740336334
recentered (3, 5)
[[ 1.0000000e+00 0.0000000e+00 0.0000000e+00 1.4901161e-09]
[ 0.0000000e+00 1.0000000e+00 -1.8730975e-09 -9.6857544e-09]
[-0.0000000e+00 1.8730975e-09 1.0000000e+00 0.0000000e+00]]
Data:
(20, 3, 5) (20, 378, 504, 3) (20, 2)
HOLDOUT view is 12
Loaded llff (20, 378, 504, 3) (120, 3, 5) [378. 504. 407.5658] ./data/nerf_llff_data/fern
Auto LLFF holdout, 8
DEFINING BOUNDS
NEAR FAR 0.0 1.0
Found ckpts ['./logs/fern_test/200000.tar']
Reloading from ./logs/fern_test/200000.tar
RENDER ONLY
test poses shape torch.Size([120, 3, 5])
0%| | 0/120 [00:00<?, ?it/s]0 0.003157377243041992
0%| | 0/120 [00:00<?, ?it/s]
Traceback (most recent call last):
File "run_nerf.py", line 858, in
train()
File "run_nerf.py", line 650, in train
rgbs, _ = render_path(render_poses, hwf, args.chunk, render_kwargs_test, gt_imgs=images, savedir=testsavedir, render_factor=args.render_factor)
File "run_nerf.py", line 154, in render_path
rgb, disp, acc, _ = render(H, W, focal, chunk=chunk, c2w=c2w[:3,:4], **render_kwargs)
File "run_nerf.py", line 126, in render
all_ret = batchify_rays(rays, chunk, **kwargs)
File "run_nerf.py", line 59, in batchify_rays
ret = render_rays(rays_flat[i:i+chunk], **kwargs)
File "run_nerf.py", line 393, in render_rays
z_samples = sample_pdf(z_vals_mid, weights[...,1:-1], N_importance, det=(perturb==0.), pytest=pytest)
File "/home/zhuxiangyang/work/nerf-pytorch/run_nerf_helpers.py", line 227, in sample_pdf
below = torch.max(torch.zeros_like(inds-1), inds-1)
RuntimeError: CUDA error: invalid device function
Segmentation fault (core dumped)

pose_spherical function

Hi @yenchenlin,

Thanks for the work on this repo! I just have a question about the function pose_spherical here. Specifically, it is not clear to me how you derive the C2W transformation from phi and theta. What is the coordinate system of your spherical coordinates? What is the reasoning behind the matrix transformation: translation, followed by rot_phi, followed by rot_theta?

Thank you!

torch.autograd.set_detect_anomaly(True) seems slow down the training

Hi,

Thanks for the work on this repo! I just found that calling this function (line 2 of run_nerf_helpers.py) can somehow slow down the training process by a large amount (almost 50% in my computer). Since this is a debugging option I'd like to suggest to turn it off as default. How do you think?

Thanks!

Can't run a pre-trained model

Hi! Thanks for the PyTorch implementation, looks great!

I tried to run pre-trained model:

python3 run_nerf.py --config configs/lego.txt --render_only

but it seems load_blender.py assumes there should be another file data/nerf_synthetic/lego/transforms_train.json, but it's not in the repo nor it comes with pre-trained models:

Traceback (most recent call last):
  File "run_nerf.py", line 860, in <module>
    train()
  File "run_nerf.py", line 570, in train
    images, poses, render_poses, hwf, i_split = load_blender_data(args.datadir, args.half_res, args.testskip)
  File "[PATH]/nerf-pytorch/load_blender.py", line 41, in load_blender_data
    with open(os.path.join(basedir, 'transforms_{}.json'.format(s)), 'r') as fp:
FileNotFoundError: [Errno 2] No such file or directory: './data/nerf_synthetic/lego/transforms_train.json'

Am I missing something?

Thanks!

A question about cuda device

Hi, I am using your code to run the lego example you provide. My GPU0 is used while GPU1 is free so I set device = torch.device("cuda:1" if torch.cuda.is_available() else "cpu") at the beginning of run_nerf.py. However, this doesn't seem to work for my second GPU:
图片

Unstable training result on Lego scene

Thanks for your work!

When I use your original code to train on Lego scene with same setting repeatedly, I get two different rendering results showing below:
PSNR30_000
PSNR32_000
Obviously, the result above is vaguer than the one below, then I check out the training log, I find the train PSNR above(mostly less than 30) is lower than the one below(mostly more than 30).

Then, I repeatedly run several experiments on the Lego scene, I find the initial Loss if Ier: 100 is unstable, leading to an unstable rendering result.

Do you have any idea about that?

P.S.: This problem is not presented on fern scene.

Scene with known camera poses

Hello, thank you for this project :)

I got a problem while training on a scene.

When I extracted the camera poses from COLMAP this is the output

kitti_exp_2_spiral_100000_rgb.mp4

the result is not so crispy as the scene is a little bit hard to learn but

But when I use the camera poses from the dataset I got a result like this

kitti_exp_pose_1_spiral_025000_rgb.mp4

The difference between the two is really great. I changed the gt camera poses to the coordinate system of right, upwards, backwards.

What am I doing wrong?

Thanks.

Failure to install torchsearchsorted

Hi Yen-Chen,

Thanks for the great work!

When I tried to install torchsearchsorted it spitted out very long error message, even after I tried my best to diagnose & make sure the dependencies for torchsearchsorted are correctly installed. I have also opened an issue in the original repo here.

My question is, can I skip the installation of torchsearchsorted? I think it takes time to solve the issue (if solvable), while I hope to play with the code during this period.

Thank you,
Koven

extract mesh

Hello, Could you provide a demo code to extract mesh?

RuntimeError: Function 'PowBackward0' returned nan values in its 0th output.

During the learning process, the following error occurs and learning is interrupted.

[TRAIN] Iter: 40300 Loss: 0.011321269907057285  PSNR: 23.059185028076172
 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                 11%|█████████████████████▎                                                                                                                                                                       | 20356/180001 [1:25:30<11:07:17,  3.99it/s][W python_anomaly_mode.cpp:104] Warning: Error detected in PowBackward0. Traceback of forward call that caused the error:
  File "run_nerf.py", line 858, in <module>
    train()
  File "run_nerf.py", line 751, in train
    img_loss0 = img2mse(extras['rgb0'], target_s)
  File "/app/nerf/run_nerf_helpers.py", line 12, in <lambda>
    img2mse = lambda x, y : torch.mean((x - y) ** 2)
 (function _print_stack)
 11%|█████████████████████▎                                                                                                                                                                       | 20356/180001 [1:25:30<11:10:36,  3.97it/s]
Traceback (most recent call last):
  File "run_nerf.py", line 858, in <module>
    train()
  File "run_nerf.py", line 755, in train
    loss.backward()
  File "/opt/conda/lib/python3.8/site-packages/torch/tensor.py", line 245, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
  File "/opt/conda/lib/python3.8/site-packages/torch/autograd/__init__.py", line 145, in backward
    Variable._execution_engine.run_backward(
RuntimeError: Function 'PowBackward0' returned nan values in its 0th output.

Here's my configuration.

expname = mydata_test
basedir = ./logs
datadir = ./data/nerf_llff_data/mydata
dataset_type = llff

factor = 8
llffhold = 8

N_rand = 1024
N_samples = 64
N_importance = 64

use_viewdirs = True
raw_noise_std = 1e0

How much memory is required to replicate the paper result?

I'm trying to replicate the nerf paper result using your code. I'm using the following config on the fern data:

factor = 4
llffhold = 8

N_rand = 4096
N_samples = 64
N_importance = 128

use_viewdirs = True
raw_noise_std = 1e0

I try to train on a single Tesla V100 GPU with 16G memory. But it runs out of memory. And even when I decrease the netchunk to 1024, and chunk to 512. It still does not work.

How much memory is required to replicate the paper result? And is there any method to train with multi-gpu if I don't have that much memory on a single GPU?

BTW, the code works well with factor=8 on fern data.

Abnormal Render Result.

Hi, thank you for your excellent work! There is a problem. When I run python run_nerf.py --config configs\fern.txt --render_only, the render result I got was weird. All intermediate images I got from ./fern_test/renderonly_path_200000 look like this:
000
I have no idea about why this happens and how to fix it.

Get poses from ARkit data

Hi,
All works fine via LLFF(COLMAP), but I have extrinsic data (quaternions and translation) from ARkit. But if simply pass my own quaternions and translation vector instead COLMAPs into img2poses script from LLFF, the result is clearly wrong. How do I need to preprocess ARkit data to make it similar to COLMAP before passing it to the img2poses script? Or what transformation do I need to do to deal with ARkit data? Or how to translate ARkit data to blender format?
I use ios_logger from this repo to get ARkit data.
Thanks!

[Question about ViewMatrix Solving process]

Hi Yen @yenchenlin ,
Thank you so much for your work in transporting nerf to PyTorch! I found a little confused
when meet with the process in solving the look-at view matrix.
The questions are listed in the code below, I sincerely hope you answer, thank you very much!

The puzzled point occurs due to the inconformity between code and the definition as below
image

def viewmatrix(z, up, center):
    """
        right-handed coordinate system.
    """
    vec2 = normalize(z)
    vec1_avg = up
    # **fixme**
    # do I need to normalize the vec1_avg = normalize(up) 
    # as well as reform the 
    # vec2 as normalize(normalize(poses[:, :3, 2].sum(0)) - center)?
    vec0 = normalize(np.cross(vec1_avg, vec2))
    vec1 = normalize(np.cross(vec2, vec0))
    m = np.stack([vec0, vec1, vec2, center], 1)
    # m (3, 4)
    return m

def poses_avg(poses):
    """
        input:  poses(N, 3, 5)
        output: c2w  (N, 3, 5)
        Last dim(4) is height, width, and focal length.
        Dim (3) is the center (Could I regard it as the eye position?) 
        Dim (2) is the z (However, I do not see a look - eye operation but only look)
        Dim (1) is the up vector, which represents the y axis.
    """

    hwf = poses[0, :3, -1:]  # (3, 1)
    center = poses[:, :3, 3].mean(0)  # (3,)
    vec2 = normalize(poses[:, :3, 2].sum(0)) # (3,)
    up = poses[:, :3, 1].sum(0)  # (3,)
    c2w = np.concatenate([viewmatrix(vec2, up, center), hwf], 1)
    
    return c2w

Python

Hi, great work. One question: what version of python does it work with?
Thx

No output video after 200k iterations on the lego dataset.

I have followed the instructions and run the "python run_nerf.py --config configs/lego.txt" command.
After 200k iterations ( the instruction claims 100k iterations), no video is output at the "logs/lego_test/lego_test_spiral_100000_rgb.mp4".

The process ended with:
image
It seems that the process exited correctly.

Where should I do to acquire the rendered video, or the output results in other formats?

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.