Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
Add lego-lowres
Browse files Browse the repository at this point in the history
Signed-off-by: Krishna Murthy <[email protected]>
  • Loading branch information
krrish94 committed Apr 16, 2020
1 parent 2bfc647 commit 3b18284
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,17 @@ A PyTorch re-implementation of [Neural Radiance Fields](http://tancik.com/nerf).
The current implementation is **_blazing fast!_** (**~9x faster** than the [original release](https://github.com/bmild/nerf), **~4x faster** than this [concurrent pytorch implementation](https://github.com/yenchenlin/nerf-pytorch))

> _What's the secret sauce behind this speedup?_
> Multiple aspects. Besides obvious enhancements such as data caching, effective memory management, etc. I drilled down through the entire NeRF codebase, and reduced data transfer b/w CPU and GPU, vectorized code where possible, and used efficient variants of pytorch ops (wrote some where unavailable). But for these changes, everything else is a faithful reproduction of the NeRF technique we all admire :)

## Sample results from the repo

<p align="center">
<img src="assets/lego-lowres.gif">
</p>


## Tiny-NeRF on Google Colab

The NeRF code release has an accompanying Colab notebook, that showcases training a feature-limited version of NeRF on a "tiny" scene. It's equivalent PyTorch notebook can be found at the following URL:
Expand Down Expand Up @@ -67,7 +75,7 @@ python train_nerf.py --config config/lego.yml --load-checkpoint path/to/checkpoi

An optional, yet simple preprocessing step of caching rays from the dataset results in substantial compute time savings (reduced carbon footprint, yay!), especially when running multiple experiments. It's super-simple: run
```bash
python cache_dataset.py --datapath cache/nerf_synthetic/lego/ --halfres False --savedir cache/legocache/legofull --num-random-rays 8192 --num-variations 500
python cache_dataset.py --datapath cache/nerf_synthetic/lego/ --halfres False --savedir cache/legocache/legofull --num-random-rays 8192 --num-variations 50
```

This samples `8192` rays per image from the `lego` dataset. Each image is `800 x 800` (since `halfres` is set to `False`), and `500` such random samples (`8192` rays each) are drawn per image. The script takes about 10 minutes to run, but the good thing is, this needs to be run only once per dataset.
Expand All @@ -82,16 +90,22 @@ A Colab notebook for the _full_ NeRF model (albeit on low-resolution data) can b

## Render fun videos

Once you've trained your NeRF, it's time to use that to render the scene. Use the `eval_nerf.py` script to do that.
Once you've trained your NeRF, it's time to use that to render the scene. Use the `eval_nerf.py` script to do that. For the `lego-lowres` example, this would be
```bash
python eval_nerf.py --config logs/experiment_id/config.yml --checkpoint logs/experiment_id/checkpoint100000.ckpt --savedir cache/rendered/experiment_id
python eval_nerf.py --config logs/lego-lowres/config.yml --checkpoint logs/lego-lowres/checkpoint200000.ckpt --savedir cache/rendered/lego-lowres
```

You can create a `gif` out of the saved images, for instance, by using [Imagemagick](https://imagemagick.org/).
```bash
convert cache/rendered/experiment_id/*.png cache/rendered/experiment_id.gif
convert cache/rendered/lego-lowres/*.png cache/rendered/lego-lowres.gif
```

This should give you a gif like this.

<p align="center">
<img src="assets/lego-lowres.gif">
</p>


## A note on reproducibility

Expand Down

0 comments on commit 3b18284

Please sign in to comment.