Coder Social home page Coder Social logo

neroic's Introduction

NeROIC: Neural Object Capture and Rendering from Online Image Collections

This repository is the official implementation of the NeROIC model from NeROIC: Neural Object Capture and Rendering from Online Image Collections by Zhengfei Kuang, Kyle Olszewski, Menglei Chai, Zeng Huang, Panos Achlioptas, and Sergey Tulyakov.

This work has been tested on Ubuntu 20.04.

Our project page is https://zfkuang.github.io/NeROIC.

Quick Start

  • Install required libraries.
conda env create -f environment.yaml
conda activate neroic
apt-get install graphicsmagick-imagemagick-compat
  • Download our example data at here. (figure_dataset, milkbox_dataset and television_dataset)

  • Optimize the geometry network.

python train.py \
--config <path_of_the_geometry_stage_config_file> \
--datadir <path of the data> 

for example:

python train.py \
--config configs/milkbox_geometry.yaml \
--datadir ./data/milkbox_dataset

(Optional) running the script with multiple GPU is a bit tricky: you should first run it a single GPU (which will generate the resized images), then stop the process before the training starts. Then run:

CUDA_VISIBLE_DEVICES=0,1,2,3 python train.py \
--config <path_of_the_geometry_stage_config_file> \
--datadir <path of the data> \
--num_gpus 4
  • Extract the normal from learned geometry.
python generate_normal.py \
 --config <path_of_the_geometry_stage_config_file> \
 --ft_path <path_of_the_geometry_network_weight_file> \
--datadir <path of the data> 

for example:

python generate_normal.py \
--config configs/milkbox_geometry.yaml \
--ft_path logs/milkbox_geometry/epoch=29.ckpt \
--datadir data/milkbox_dataset
  • Optimize the rendering network.
python train.py \
--config <path_of_the_rendering_stage_config_file> \
--ft_path <path_of_the_geometry_network_weight_file> \
--datadir <path of the data> 

for example (training with 4 GPUs):

CUDA_VISIBLE_DEVICES=0,1,2,3 python train.py \
--config configs/milkbox_rendering.yaml \
--ft_path logs/milkbox_geometry/epoch=29.ckpt \
--datadir data/milkbox_dataset \
--num_gpus 4

training logs & results will be saved at logs/.

Video Generation

the video of novel testing views is generated on-the-fly during training, and saved under logs/. To render video with a pre-trained model, run:

python train.py \
--config <path_of_the_config_file> \
--ft_path <path_of_the_model_weight_file> \
--datadir <path of the data> \
--i_video 1 \ 
(optional) --test_img_id <index_of_the_reference_image>

Testing

We provide additional testing scripts for material decomposition and relighting.

To decompose materials:

python test_material.py \
--config <path_of_the_rendering_stage_config_file> \
--ft_path <path_of_the_rendering_network_weight_file> \
--datadir <path of the data> 

To relight the model (panoramic exr HDRI maps are prefered):

python test_relighting.py \
--config <path_of_the_rendering_stage_config_file> \
--ft_path <path_of_the_rendering_network_weight_file> \
--datadir <path of the data> \
--test_env_filename <path_of_the_envrionment_map> 

Bring Your Own Data

To train NeROIC with your own collected data, click here.

Model Overview

Our two-stage model takes images of an object from different conditions as input. With the camera poses of images and object foreground masks acquired by other state-of-the-art methods, We first optimize the geometry of scanned object and refine camera poses by training a NeRF-based network; We then compute the surface normal from the geometry (represented by density function) using our normal extraction layer; Finally, our second stage model decomposes the material properties of the object and solves for the lighting conditions for each image.

Screenshot

Novel View Synthesis

Given online images from a common object, our model can synthesize novel views of the object with the lighting conditions from the training images.

nvs.mp4

Screenshot

Material Decomposition

material.mp4

Screenshot

Relighting

relighting.mp4

Citation

If you find this useful, please cite the following:

@article{10.1145/3528223.3530177,
author = {Kuang, Zhengfei and Olszewski, Kyle and Chai, Menglei and Huang, Zeng and Achlioptas, Panos and Tulyakov, Sergey},
title = {NeROIC: Neural Rendering of Objects from Online Image Collections},
year = {2022},
issue_date = {July 2022},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
volume = {41},
number = {4},
issn = {0730-0301},
url = {https://doi.org/10.1145/3528223.3530177},
doi = {10.1145/3528223.3530177},
journal = {ACM Trans. Graph.},
month = {jul},
articleno = {56},
numpages = {12},
keywords = {neural rendering, reflectance & shading models, multi-view & 3D}
}

Acknowledgements: This work borrows many code from NeRF-pl. We thank the author for releasing his code.

neroic's People

Contributors

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

neroic's Issues

Pre-trained Model

Hi, thank you for sharing the code. Is the pre-trained model available? Thanks!

hope someone will set this up on colab!

would be great to have a colab for this , where the user could upload three image or more , from different view points and then get this 3d model out.

Would be extremely useful.

can not train

image

ValueError: The provided lr scheduler "<torch.optim.lr_scheduler.StepLR object at 0x7f5c0c38e6d0>" is invalid

how long does this take to run?

I know it depends on the strength and number of GPUs used so I guess how long did it take for whatever you used in NeROIC's creation / testing?

Relighting problems

Thanks to the authors for your contributions. Here I have some questions about relighting:

  1. When I run test_relighting.py using milkbox sample with an outdoor image (download from google), but the relighting results seem a littie bad. After checking the code, I found that the relighting results were highly dependent on the setting of args.test_env_maxthres. I am curious about how to choose the env image and set the args.test_env_maxthres to achieve the better relighting results?

The outdoor image we used while tesing the milkbox sample:
outdoor

The relighting results:
temp

  1. In section 3.5 of the paper it is introduced that the purpose of Rendering Networks is to estimate the lighting of each input image and the material properties of the object, but the self.env_lights in class NeROICRenderer keeps the value unchanged since the initialization. I am curious about how to the network learning the various illumination conditions?

Image names covered in brine, custom datasets and LLFF compatibility

Your dataset structure follows common LLFF, and I understand that the main issue with custom datasets and LLFF is the lack of file names being presented to the model. I had similar issues with nvdiffrec and a simple list solves any number of memory leaks that happen when loading images/files rejected by colmap.

a "view_imgs.txt" is pretty important I'd think, and I'm glad some of the example datasets use a poses.npy -I do not understand the reasoning to use remove.bg masks, construct datasets with another .db file, and pickle a list of files (instead of a readable .txt) that users might want to edit when making their own sets.

if os.path.exists(os.path.join(mask_dir, "%s-removebg-preview.png"%img_id)):
when I am trying to handle masks, in their own separate folder, would I want them just to be a b/w image out of any number of salient object matting repos, or images specifically from remove.bg of a separate size (to then use bicubic filtering on), only in the alpha, and containing an entire unused image?

There are 0 technological limitations on making a dataset renderable and testable in instant-ngp, meshable in nvdiffrec (and this repo), optimizable in AdaNeRF and R2L, and still be created from a video shot on a phone. If you're planning on making a dataset creation guide, please dont use removebg filenames, dont use new db files, dont use non user-readable lists of files (it takes one extra line to parse a .txt file), and have support for traditional b/w masks.
all that's needed is /images, /masks, imgs.txt, and a poses.npy (pts seems like it's to build a bounding box and isn't in all your example sets)
lowering that barrier allows anyone who knows how to run a script to make datasets, and it's WHY instant-ngp worked, anyone could try it out with ffmpeg and a script. Forks are being made to test datasets made from my colmap2poses script, if a simple colmap2NeROIC script is needed to read colmap data I can make a push with a more forgiving LLFF dataloader and said script.

Segmentation masks

Hi, what kind of a method can be used to get the black and white masks needed to run this on a custom dataset?

Question on Foreground Masks

The masks in provided data seem perfect. I am working on my own data and wondering if it can work with noisy foreground mask coming from a saliency detection model or it has to be perfect foreground mask. Thanks!

Error in dataset.py , to fix add additional check in padding function in ./dataset/dataset.py

when i was training i was getting
Screenshot_20230509_183842

this is because image dimension is greater than sh, thus need to add additional check in padding function
def padding(img, sh, pad_value=0):
if sh[0]<img.shape[0]:
new_w,new_h=int(img.shape[1]/img.shape[0])*sh[0],sh[0]
print(new_w,new_h,type(img))
img=cv2.resize(img.astype(np.uint8),(new_w,new_h))
elif sh[1]<img.shape[1]:
new_h,new_w=int(img.shape[0]/img.shape[1])*sh[1],sh[1]
img=cv2.resize(img.astype(np.uint8),(new_w,new_h))
else:
img=img
if img.ndim == 2:
return np.pad(img, [(0,sh[0]-img.shape[0]), (0, sh[1]-img.shape[1])], 'constant', constant_values=pad_value)
else:
return np.pad(img, [(0,sh[0]-img.shape[0]), (0, sh[1]-img.shape[1]), (0,0)], 'constant', constant_values=pad_value)

Perform baddly on validation set

I use the milkbox dataset to train the model and the training PSNR is about 29.
However, the images synthesis in validation are nearly blank with a little noise, and the PSNR is extremely low. Is it overfitting?

I just run like this for the geometry model:

python train.py
--config
configs/milkbox_geometry.yaml
--datadir
data\milkbox_dataset

Results not as good on custom dataset

Hello!
I have been training the network on my own data and the rendering results are way worse than the ones from training on the provided datasets. I trained on a dataset that has 53 images. I kept the same parameters for the config files, changing the image size and name, of course.

One of the input images:
2
And these are the result images taken from the logs folder:
00
train_01
Visualizing the dense output from colmap:
Screenshot from 2022-09-08 11-26-43

What could be the possible reasons for such results?

Help! While running the code, an error occurred.

In the process of running the code 'python train.py --config configs/milkbox_geometry.yaml --datadir ./data/milkbox_dataset', an error occurs, prompting 'AttributeError: module 'keras.backend' has no attribute 'is_tensor'
' Error, please, how do I fix this? Thanks!

Can NeROIC run on CPU?

I modifid train.py\ generate_normal.py\dataset.py to cpu device type。
Then I execute code python train.py \ --config configs/milkbox_geometry.yaml \ --datadir ./data/milkbox_dataset.
But there not generate 'epoch=29.ckpt' file

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.