From deae4a88cb9870c2b819badbaca2c794edbce55f Mon Sep 17 00:00:00 2001 From: Krishna Murthy Date: Wed, 15 Apr 2020 07:25:46 -0400 Subject: [PATCH] Package core utils Signed-off-by: Krishna Murthy --- cache_dataset.py | 6 +++--- eval_nerf.py | 12 ++++++------ nerf/__init__.py | 8 ++++++++ cfgnode.py => nerf/cfgnode.py | 0 load_blender.py => nerf/load_blender.py | 0 load_llff.py => nerf/load_llff.py | 0 metrics.py => nerf/metrics.py | 0 models.py => nerf/models.py | 0 nerf_helpers.py => nerf/nerf_helpers.py | 0 train_utils.py => nerf/train_utils.py | 6 +++--- .../volume_rendering_utils.py | 2 +- tiny_nerf.py | 2 +- train_nerf.py | 12 ++++++------ 13 files changed, 28 insertions(+), 20 deletions(-) create mode 100644 nerf/__init__.py rename cfgnode.py => nerf/cfgnode.py (100%) rename load_blender.py => nerf/load_blender.py (100%) rename load_llff.py => nerf/load_llff.py (100%) rename metrics.py => nerf/metrics.py (100%) rename models.py => nerf/models.py (100%) rename nerf_helpers.py => nerf/nerf_helpers.py (100%) rename train_utils.py => nerf/train_utils.py (97%) rename volume_rendering_utils.py => nerf/volume_rendering_utils.py (97%) diff --git a/cache_dataset.py b/cache_dataset.py index 7e74a0a..09bf393 100644 --- a/cache_dataset.py +++ b/cache_dataset.py @@ -10,9 +10,9 @@ import torch from tqdm import tqdm -from load_blender import load_blender_data -from load_llff import load_llff_data -from nerf_helpers import get_ray_bundle, meshgrid_xy +from nerf import load_blender_data +from nerf import load_llff_data +from nerf import get_ray_bundle, meshgrid_xy def cache_nerf_dataset(args): diff --git a/eval_nerf.py b/eval_nerf.py index 29fb27d..4ad3158 100644 --- a/eval_nerf.py +++ b/eval_nerf.py @@ -9,12 +9,12 @@ import yaml from tqdm import tqdm -import models -from cfgnode import CfgNode -from load_blender import load_blender_data -from load_llff import load_llff_data -from nerf_helpers import get_ray_bundle, positional_encoding -from train_utils import run_one_iter_of_nerf +from nerf import models +from nerf import CfgNode +from nerf import load_blender_data +from nerf import load_llff_data +from nerf import get_ray_bundle, positional_encoding +from nerf import run_one_iter_of_nerf def cast_to_image(tensor): diff --git a/nerf/__init__.py b/nerf/__init__.py new file mode 100644 index 0000000..b5e2e39 --- /dev/null +++ b/nerf/__init__.py @@ -0,0 +1,8 @@ +from .cfgnode import CfgNode +from .load_blender import load_blender_data +from .load_llff import load_llff_data +from .models import * +from .nerf_helpers import * +from .train_utils import * +from .volume_rendering_utils import * + diff --git a/cfgnode.py b/nerf/cfgnode.py similarity index 100% rename from cfgnode.py rename to nerf/cfgnode.py diff --git a/load_blender.py b/nerf/load_blender.py similarity index 100% rename from load_blender.py rename to nerf/load_blender.py diff --git a/load_llff.py b/nerf/load_llff.py similarity index 100% rename from load_llff.py rename to nerf/load_llff.py diff --git a/metrics.py b/nerf/metrics.py similarity index 100% rename from metrics.py rename to nerf/metrics.py diff --git a/models.py b/nerf/models.py similarity index 100% rename from models.py rename to nerf/models.py diff --git a/nerf_helpers.py b/nerf/nerf_helpers.py similarity index 100% rename from nerf_helpers.py rename to nerf/nerf_helpers.py diff --git a/train_utils.py b/nerf/train_utils.py similarity index 97% rename from train_utils.py rename to nerf/train_utils.py index 65ee79f..e92ae15 100644 --- a/train_utils.py +++ b/nerf/train_utils.py @@ -1,8 +1,8 @@ import torch -from nerf_helpers import get_minibatches, ndc_rays -from nerf_helpers import sample_pdf_2 as sample_pdf -from volume_rendering_utils import volume_render_radiance_field +from .nerf_helpers import get_minibatches, ndc_rays +from .nerf_helpers import sample_pdf_2 as sample_pdf +from .volume_rendering_utils import volume_render_radiance_field def run_network(network_fn, pts, ray_batch, chunksize, embed_fn, embeddirs_fn): diff --git a/volume_rendering_utils.py b/nerf/volume_rendering_utils.py similarity index 97% rename from volume_rendering_utils.py rename to nerf/volume_rendering_utils.py index cb1b2f4..711426f 100644 --- a/volume_rendering_utils.py +++ b/nerf/volume_rendering_utils.py @@ -1,6 +1,6 @@ import torch -from nerf_helpers import cumprod_exclusive +from .nerf_helpers import cumprod_exclusive def volume_render_radiance_field( diff --git a/tiny_nerf.py b/tiny_nerf.py index 612dcee..41142c1 100644 --- a/tiny_nerf.py +++ b/tiny_nerf.py @@ -6,7 +6,7 @@ import torch from tqdm import tqdm, trange -from nerf_helpers import ( +from nerf import ( cumprod_exclusive, get_minibatches, get_ray_bundle, diff --git a/train_nerf.py b/train_nerf.py index 3932381..c870f51 100644 --- a/train_nerf.py +++ b/train_nerf.py @@ -10,18 +10,18 @@ from torch.utils.tensorboard import SummaryWriter from tqdm import tqdm, trange -import models -from cfgnode import CfgNode -from load_blender import load_blender_data -from load_llff import load_llff_data -from nerf_helpers import ( +from nerf import models +from nerf import CfgNode +from nerf import load_blender_data +from nerf import load_llff_data +from nerf import ( get_ray_bundle, img2mse, meshgrid_xy, mse2psnr, positional_encoding, ) -from train_utils import run_one_iter_of_nerf +from nerf import run_one_iter_of_nerf def main():