diff --git a/nerfstudio/cameras/camera_utils.py b/nerfstudio/cameras/camera_utils.py index e9b11bd3b..6399265a5 100644 --- a/nerfstudio/cameras/camera_utils.py +++ b/nerfstudio/cameras/camera_utils.py @@ -366,7 +366,8 @@ def radial_and_tangential_undistort( if distortion_params.shape[-1] == 0: return coords - elif distortion_params.shape[-1] < 8: + + if distortion_params.shape[-1] < 8: distortion_params = F.pad(distortion_params, (0, 8 - distortion_params.shape[-1]), "constant", 0.0) assert distortion_params.shape[-1] == 8 diff --git a/nerfstudio/cameras/cameras.py b/nerfstudio/cameras/cameras.py index 3ab732155..699c1e920 100644 --- a/nerfstudio/cameras/cameras.py +++ b/nerfstudio/cameras/cameras.py @@ -17,7 +17,6 @@ Camera Models """ import base64 import math -import os from dataclasses import dataclass from enum import Enum, auto from typing import Dict, List, Optional, Tuple, Union @@ -35,7 +34,6 @@ from nerfstudio.cameras import camera_utils from nerfstudio.cameras.rays import RayBundle from nerfstudio.data.scene_box import SceneBox from nerfstudio.utils import profiler -from nerfstudio.utils.misc import strtobool from nerfstudio.utils.tensor_dataclass import TensorDataclass TORCH_DEVICE = Union[torch.device, str] # pylint: disable=invalid-name @@ -659,7 +657,7 @@ class Cameras(TensorDataclass): coord_stack[coord_mask, :].reshape(3, -1, 2), distortion_params[mask, :], ).reshape(-1, 2) - except: + except ImportError: coord_stack[coord_mask, :] = camera_utils.radial_and_tangential_undistort( coord_stack[coord_mask, :].reshape(3, -1, 2), distortion_params[mask, :], @@ -670,12 +668,11 @@ class Cameras(TensorDataclass): if mask.any(): if distortion_params_delta is not None: raise NotImplementedError("Fisheye distortion optimization is not implemented") - else: - # use nerfacc with do not provide gradient - coord_stack[coord_mask, :] = opencv_lens_undistortion_fisheye( - coord_stack[coord_mask, :].reshape(3, -1, 2), - distortion_params[mask, :], - ).reshape(-1, 2) + # use nerfacc which does not provide gradient + coord_stack[coord_mask, :] = opencv_lens_undistortion_fisheye( + coord_stack[coord_mask, :].reshape(3, -1, 2), + distortion_params[mask, :], + ).reshape(-1, 2) # Make sure after we have undistorted our images, the shapes are still correct assert coord_stack.shape == (3,) + num_rays_shape + (2,) diff --git a/nerfstudio/data/datamanagers/base_datamanager.py b/nerfstudio/data/datamanagers/base_datamanager.py index 60d335e12..976833074 100644 --- a/nerfstudio/data/datamanagers/base_datamanager.py +++ b/nerfstudio/data/datamanagers/base_datamanager.py @@ -548,14 +548,12 @@ class VanillaDataManager(DataManager): # pylint: disable=abstract-method def get_train_rays_per_batch(self) -> int: if self.train_pixel_sampler is None: return self.config.train_num_rays_per_batch - else: - return self.train_pixel_sampler.num_rays_per_batch + return self.train_pixel_sampler.num_rays_per_batch def get_eval_rays_per_batch(self) -> int: if self.eval_pixel_sampler is None: return self.config.eval_num_rays_per_batch - else: - return self.eval_pixel_sampler.num_rays_per_batch + return self.eval_pixel_sampler.num_rays_per_batch def get_datapath(self) -> Path: return self.config.dataparser.data diff --git a/nerfstudio/data/dataparsers/instant_ngp_dataparser.py b/nerfstudio/data/dataparsers/instant_ngp_dataparser.py index 8682430f5..367da5c03 100644 --- a/nerfstudio/data/dataparsers/instant_ngp_dataparser.py +++ b/nerfstudio/data/dataparsers/instant_ngp_dataparser.py @@ -25,7 +25,6 @@ import numpy as np import torch from rich.console import Console -from nerfstudio.cameras import camera_utils from nerfstudio.cameras.cameras import Cameras, CameraType from nerfstudio.data.dataparsers.base_dataparser import ( DataParser, diff --git a/nerfstudio/model_components/ray_generators.py b/nerfstudio/model_components/ray_generators.py index 12f58f119..d9e1e14a0 100644 --- a/nerfstudio/model_components/ray_generators.py +++ b/nerfstudio/model_components/ray_generators.py @@ -17,7 +17,6 @@ Ray generator. """ from typing import Optional -import torch from torch import nn from torchtyping import TensorType diff --git a/nerfstudio/models/nerfplayer_ngp.py b/nerfstudio/models/nerfplayer_ngp.py index 59a0743bc..1211da5fa 100644 --- a/nerfstudio/models/nerfplayer_ngp.py +++ b/nerfstudio/models/nerfplayer_ngp.py @@ -105,7 +105,7 @@ class NerfplayerNGPModel(NGPModel): self.field = NerfplayerNGPField( aabb=self.scene_box.aabb, - use_appearance_embedding=self.config.use_appearance_embedding, + use_appearance_embedding=False, num_images=self.num_train_data, temporal_dim=self.config.temporal_dim, num_levels=self.config.num_levels, @@ -119,9 +119,8 @@ class NerfplayerNGPModel(NGPModel): self.scene_aabb = Parameter(self.scene_box.aabb.flatten(), requires_grad=False) # Occupancy Grid - grid_scale = 1 << (self.config.grid_levels - 1) self.occupancy_grid = nerfacc.OccGridEstimator( - roi_aabb=nerfacc.grid._enlarge_aabb(self.scene_aabb, 1.0 / grid_scale), + roi_aabb=self.scene_aabb, resolution=self.config.grid_resolution, levels=self.config.grid_levels, )