From 934f5e9fcc6cd1d56b886ff7356fb99e49379d3a Mon Sep 17 00:00:00 2001 From: Matthew Tancik Date: Tue, 18 Oct 2022 12:55:42 -0700 Subject: [PATCH] Support python 3.7 (#77) * Support python 3.7 * Add dependency --- examples/train_mlp_dnerf.py | 4 ++-- examples/train_mlp_nerf.py | 4 ++-- examples/train_ngp_nerf.py | 4 ++-- nerfacc/version.py | 6 +++++- pyproject.toml | 3 ++- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/examples/train_mlp_dnerf.py b/examples/train_mlp_dnerf.py index 7c1c14e5..9702ee35 100644 --- a/examples/train_mlp_dnerf.py +++ b/examples/train_mlp_dnerf.py @@ -185,7 +185,7 @@ elapsed_time = time.time() - tic loss = F.mse_loss(rgb[alive_ray_mask], pixels[alive_ray_mask]) print( - f"elapsed_time={elapsed_time:.2f}s | {step=} | " + f"elapsed_time={elapsed_time:.2f}s | step={step} | " f"loss={loss:.5f} | " f"alive_ray_mask={alive_ray_mask.long().sum():d} | " f"n_rendering_samples={n_rendering_samples:d} | num_rays={len(pixels):d} |" @@ -235,7 +235,7 @@ # ) # break psnr_avg = sum(psnrs) / len(psnrs) - print(f"evaluation: {psnr_avg=}") + print(f"evaluation: psnr_avg={psnr_avg}") train_dataset.training = True if step == max_steps: diff --git a/examples/train_mlp_nerf.py b/examples/train_mlp_nerf.py index 7705dceb..aa114a44 100644 --- a/examples/train_mlp_nerf.py +++ b/examples/train_mlp_nerf.py @@ -211,7 +211,7 @@ elapsed_time = time.time() - tic loss = F.mse_loss(rgb[alive_ray_mask], pixels[alive_ray_mask]) print( - f"elapsed_time={elapsed_time:.2f}s | {step=} | " + f"elapsed_time={elapsed_time:.2f}s | step={step} | " f"loss={loss:.5f} | " f"alive_ray_mask={alive_ray_mask.long().sum():d} | " f"n_rendering_samples={n_rendering_samples:d} | num_rays={len(pixels):d} |" @@ -257,7 +257,7 @@ # ) # break psnr_avg = sum(psnrs) / len(psnrs) - print(f"evaluation: {psnr_avg=}") + print(f"evaluation: psnr_avg={psnr_avg}") train_dataset.training = True if step == max_steps: diff --git a/examples/train_ngp_nerf.py b/examples/train_ngp_nerf.py index 5715e529..9b8203aa 100644 --- a/examples/train_ngp_nerf.py +++ b/examples/train_ngp_nerf.py @@ -254,7 +254,7 @@ def occ_eval_fn(x): elapsed_time = time.time() - tic loss = F.mse_loss(rgb[alive_ray_mask], pixels[alive_ray_mask]) print( - f"elapsed_time={elapsed_time:.2f}s | {step=} | " + f"elapsed_time={elapsed_time:.2f}s | step={step} | " f"loss={loss:.5f} | " f"alive_ray_mask={alive_ray_mask.long().sum():d} | " f"n_rendering_samples={n_rendering_samples:d} | num_rays={len(pixels):d} |" @@ -301,7 +301,7 @@ def occ_eval_fn(x): # ) # break psnr_avg = sum(psnrs) / len(psnrs) - print(f"evaluation: {psnr_avg=}") + print(f"evaluation: psnr_avg={psnr_avg}") train_dataset.training = True if step == max_steps: diff --git a/nerfacc/version.py b/nerfacc/version.py index 6c5dc941..97452e92 100644 --- a/nerfacc/version.py +++ b/nerfacc/version.py @@ -1,6 +1,10 @@ """ Copyright (c) 2022 Ruilong Li, UC Berkeley. """ -from importlib.metadata import version +try: + from importlib.metadata import version +except ImportError: + # Running on pre-3.8 Python; use importlib-metadata package + from importlib_metadata import version __version__ = version("nerfacc") diff --git a/pyproject.toml b/pyproject.toml index 1973b791..452a78cc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,8 +9,9 @@ description = "A General NeRF Acceleration Toolbox." readme = "README.md" authors = [{name = "Ruilong", email = "ruilongli94@gmail.com"}] license = { text="MIT" } -requires-python = ">=3.8" +requires-python = ">=3.7" dependencies = [ + "importlib_metadata>=5.0.0; python_version<'3.8'", "ninja>=1.10.2.3", "pybind11>=2.10.0", "torch>=1.12.0",