Giter Club home page Giter Club logo

tensoir's Introduction

TensoIR: Tensorial Inverse Rendering (CVPR 2023)

This repository contains a pytorch implementation for the paper: TensoIR: Tensorial Inverse Rendering.

The code can run well, but it is not well organized. I may re-organize the code when I am available.

overview.mp4

Tested on Ubuntu 20.04 + Pytorch 1.10.1

Install environment:

conda create -n TensoIR python=3.8
conda activate TensoIR
pip install torch==1.10 torchvision
pip install tqdm scikit-image opencv-python configargparse lpips imageio-ffmpeg kornia lpips tensorboard loguru plyfile

Dataset

Downloading

Please download the dataset and environment maps from the following links and put them in the ./data folder:

  • TensoIR-Synthetic We provide a TensoIR-Synthetic dataset for training and testing. The dataset is rendered by Blender and consists of four complex synthetic scenes (ficus, lego, armadillo, and hotdog). We use the same camera settings as NeRFactor, so we have 100 training views and 200 test views. For each view, we provide the normals map, albedo map and multiple RGB images (11 images) under different lighting conditions. More details about the dataset and our multi-light settings can be found in the supplementary material of our paper.
  • NeRF-Synthetic Original NeRF-Synthetic dataset is not widely used for inverse rendering work, as some scenes of it are not entirely rendered with the environment map and some objects' materials cannot be well handled by the simplfied BRDF model(as discussed in the "limitations" section of our paper's supplementary material). But we still provide the original NeRF-Synthetic dataset to facilitate the analysis of our work.
  • Environment Maps The file folder has environment maps of different resoluitions($2048 \times 1024$ and $1024 \times 512$). We use the relatively lower resolution environment maps for relighting-testing because of the limited GPU memory, though the G.T. data is rendered by high-resolution environment maps. You can also use the higher resolution environment map for relighting-testing if you have enough GPU memory.

Generating your own synthetic dataset

We provide the code for generating your own synthetic dataset with your own blender files and Blender software. Please download this file and follow the readme.md file inside it to render your own dataset. The Blender rendering scripts heavily rely on the code provided by NeRFactor. Thanks for its great work!

Training

Note:

  1. After finishing all training iterations, the training script will automatically render the all test images under the learned lighting condition and save them in the log folder. It will also compute all metrics related to geometry, materials, and novel view synthesis(except for relighting). The results will be saved in the log folder as well.
  2. Different scenes have different config files. The main difference of those config files is the different weight value for normals_diff_weight, which controls the how close the predicted normals should be to the derived normals. Larger weight will help preventing the normals prediction from overfiting the surpervised colors, but at the same time it will demage the normals prediction network's ability to predict high-frequency details. We recommend three values to try: 0.0005, 0.002, and 0.005 when you train TensoIR on your own dataset.

For pretrained checkpoints and results please see:

Checkpoints Results

Training under single lighting condition

export PYTHONPATH=. && python train_tensoIR.py --config ./configs/single_light/armadillo.txt

Training under rotated multi-lighting conditions

export PYTHONPATH=. && python train_tensoIR_rotated_multi_lights.py  --config ./configs/multi_light_rotated/hotdog.txt

Training under general multi-lighting conditions

export PYTHONPATH=. && python train_tensoIR_general_multi_lights.py  --config ./configs/multi_light_general/ficus.txt

(Optional) Training for the original NeRF-Synthetic dataset

We don't do quantitative and qualitative comparisons for the original NeRF-Synthetic dataset in our paper (the reasons have been discussed above), but you can still train TensoIR on the original NeRF-Synthetic dataset for some analysis.

export PYTHONPATH=. && python train_tensoIR_simple.py --config ./configs/single_light/blender.txt

Testing and Validation

Rendering with a pre-trained model under learned lighting condition

export PYTHONPATH=. && python "$training_file" --config "$config_path" --ckpt "$ckpt_path" --render_only 1 --render_test 1

"$training_file" is the training script you used for training, e.g. train_tensoIR.py or train_tensoIR_rotated_multi_lights.py or train_tensoIR_general_multi_lights.py.

"$config_path" is the path to the config file you used for training, e.g. ./configs/single_light/armadillo.txt or ./configs/multi_light_rotated/hotdog.txt or ./configs/multi_light_general/ficus.txt.

"$ckpt_path" is the path to the checkpoint you want to test.

The result will be stored in --basedir defined in the config file.

Relighting with a pre-trained model under unseen lighting conditions

export PYTHONPATH=. && python scripts/relight_importance.py --ckpt "$ckpt_path" --config configs/relighting_test/"$scene".txt --batch_size 800

We do light intensity importance sampling for relighting. The sampling results are stored in --geo_buffer_path defined in the config file.

"$ckpt_path" is the path to the checkpoint you want to test.

"$scene" is the name of the scene you want to relight, e.g. armadillo or ficus or hotdog or lego.

Reduce the --batch_size if you have limited GPU memory.

The line 370 of scripts/relight_importance.py specifies the names of environment maps for relighting. You can change it if you want to test other unseen lighting conditions.

Extracting mesh

The mesh will be stored in the same folder as the checkpoint.

export PYTHONPATH=. && python scripts/export_mesh.py --ckpt "$ckpt_path" 

Citations

If you find our code or paper helps, please consider citing:

@inproceedings{Jin2023TensoIR,
  title={TensoIR: Tensorial Inverse Rendering},
  author={Jin, Haian and Liu, Isabella and Xu, Peijia and Zhang, Xiaoshuai and Han, Songfang and Bi, Sai and Zhou, Xiaowei and Xu, Zexiang and Su, Hao},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
  year={2023}
}

Acknowledgement

The code was built on TensoRF. Thanks for this great project!

tensoir's People

Contributors

haian-jin 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

tensoir's Issues

Questions about the radiance field color loss

Excellent work! Here is my question:
Is the radiance field color (computing by volume rendering) uesd as the indirect lighting, same as the radiance field color used in the loss L_RF? If so, Why does the indirect lighting need to be consistent with GT color?
I apologize for the possible error in my understanding. Looking forward to your answer and thank you for your excellent work!

release date

Thanks for your great work!
Will the code be released today? really looking forward to it!

Artifacts observed on synthetic hotdog with single lighting

Hi, thank you very much for making your work publicly available.

Unfortunately, while I was trying to reproduce your experimental results on synthetic hotdog, a strange artifact was observed in a specific area in the scene as shown in the pictures below.
albedo
normal

I followed your instructions for setting up python environment and used "configs/single_light/hotdog.txt" configuration provided in the codebase. Running the experiment multiple times or setting a different random seed value doesn't seem to resolve this issue. So I was wondering if I can get some help here.

Thanks in advance!

Problems Generating My new dataset

Hello! Thanks for your great work. We are really impressed by reconstruction quality has achieved.
We had followed 'Generating your own synthetic dataset' for the code generating out new scenes with a single small cube, and try to reconstruct it by this project.
However we found it doesn't work and the reuslt is pretty blurry. We had made the backgroud transparency like the armadillo in TensoIR-Synthetic.(using train_tensoIR.py )
After diving into the code about photos genreation and this project, we found the code to genreate new pictures with blender reamin some inconsistency with this project, especially generating camera params in the json file(camera_angle_x, rotation, rgba_xxsscene_000.png etc) I had fixed some, but it still remain some inconsistency.
Would you give me some advice about how to import my own scenes description into this project?(orientation of Z-axis, or is 'rotation' used in json? ) Or maybe could you share me you latest dataset generation code for blender?(the code in 'Generating your own synthetic dataset' dosen't seems to be latest)
Thanks!
(I am sorry maybe I am not a good English Speaker, if you feeled confused what I am talking about, maybe I can use Chinese

Question about the rescale ratio for diffuse color

Hi,

I am a student with a keen interest in the topic at hand. While exploring your repository, I came across the "relight_importance.py" script and noticed the presence of a "compute_rescale_ratio" function.
It appears that this computed ratio is intended for the purpose of rescaling the diffuse color.
I am curious to understand the specific rationale behind this rescaling process. In my view, it might be possible to achieve the desired relighting results using the original, unaltered diffuse color.

Thanks for your amazing work and look forward to your reply.

Doubts about the failure of the environment map estimation

Hello, thank you for your excellent work.
I would like to add the SDF field to your work for further reconstruction. I used the geometric representation of neus while retaining the density tensor. I tried it on the 'hotdog' scene of the Blender dataset.
(1) The estimation of the environment map was found to be unreasonable, and the estimated albedo was severely darkened. Here is the environment map.
YTSG8IEP2UQN3GBGT{9ELWY

(2) Besides, the estimated RGB image (nvs with radiance field) seems to have grids, which is not smooth and continuous.
P_L3XR2Q5N%E)Y2L{ V8383

Could you give me some suggestions about it? Any reply will be appreciated.

Troubleshooting Unbounded Scene

Hello, I am trying to experiment with applying TensoIR to an unbounded scene.

I started with trying the well-known "Garden" scene from the MipNeRF-360 dataset.

I'm not sure if this will be the only issue, but one problem that I have run into is the following, where it seems that the scene geometry is limited to a bounding box that is much smaller than the full scene. This also seems like it leads to incorrect optimization of the geometry/normals:

020

Do you have any ideas as to what I may do to resolve this bounding box issue and improve results?

Thanks very much!

dataset's website can't log in

Thanks to your code!!
I am a student in another university and interesting in nerf and computer graphics and want to follow your work.But I have no zju email and can't regist.
Can you share the dataset by other ways?
Thanks!!

Limitation on glossy materials

Thank you again for this insightful research project and for providing us with the source code.

I was trying to track down an issue related to glossy estimation. I did a simple test where I optimize a glossy scene and then render novel views by setting the roughness value (after volume rendering is done) such that every 800x800 pixels has a roughness of 0. I tried other values but it seems that values lower than 0.5 cause issues. Below, I am showing results for different r values:

I did an ablation for r=0.2, the strange highlights seem to be coming from the directly lit specular component:
image

Do you know why there happens to be artefacts for r=0.2 ; while r=0 looks very matte? Let me know if I overlooked something.

How to Extract maps which can be used in UE?

Great job. I have seen that it is possible to export mesh, but I would like to know how to export texture maps so that they can be used in UE rendering engines effectively. Thanks a lot.

[Code] Enable gradient in renderer.py

An amazing work and congrats! I have a question in the code and hope for a reply if you're convenient. In the file renderer.py Line 37, the TensoIR model is warped by torch.enable_grad(), so I wonder why we need the gradient here?

How to get nice lego geometry?

Thank you first for the great work.
I tried the model on NeRFactor dataset (512x512 with low res. env. map). The results of the Lego scene make me confused.

Result in the paper:
Screenshot from 2023-05-10 11-14-24

Result of the standard Lego config, the result is blur and has an unexcepted 'bottom' part:
039

Result of the 'tricky' Lego config (enable the those three lines), the result looks better but still it has 1. tricky normal direction in some part, 2. noisy normal for the flat surface and 3. not correct surface reconstruction inside the digging bucket:
039

As can be seen, training with either standard lego config or the tricky one can not produce results as good as in the paper. One reason is that I trained it with a smaller image size (512x512, in the paper 800x800). Do you have any suggestions for getting a better geometry?

Results on out-bounded scenes ?

Hello,
thanks for your great work and for open sourcing your code. It is really a nice paper.

For my use case, I need to learn (and relight accurately) an outbounded scene (such as the ones in Mip-NeRF360, although with multiple lights). Have you tried running your algorithm on such scenes? Did it perform well, or should I look for other works ?

The nerf synthetic dataset cannot be trained

Thank you very much for your excellent work. I get an error when I train the synthetic dataset for nerf:
image
The format of the nerf synthetic dataset is as follows:
image
Looking at the error, it seems to ask for a metadata.json file.
But when I look at the metadata.json file in the dataset you provided, it looks like HDR is required!
image
Is HDR a required input?

Out of memory when training on custom blender scene

Hi, thank you for this exciting paper.

I was looking to run the training on a custom blender scene. I used the utility files to render the full dataset from a user defined blender file. While I manage to train the full 80k steps on the single light armadillo experiment, I am unable to do so on a custom dataset because of a memory issue (gpu used is also 11GB). This happens at the 10k mark. From what I understand, 10k is when you start upsampling the vector and matrix sizes. Just after the 10k steps, the training fails with an out of memory error. What I don't understand is why this happens on my custom scene while the provide scene works correctly.

Is this related to the fact the alpha mask is being computed at that point?
Do you have any pointers as what would be causing this issue?

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.