mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-05 07:18:57 +08:00
fix linting
This commit is contained in:
1 parent
b02f376f25
commit
97c411ea52
6 files changed
+12
-19
No files matched your search
@@ -366,7 +366,8 @@ def radial_and_tangential_undistort(
|
|||||||
|
|
||||||
if distortion_params.shape[-1] == 0:
|
if distortion_params.shape[-1] == 0:
|
||||||
return coords
|
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)
|
distortion_params = F.pad(distortion_params, (0, 8 - distortion_params.shape[-1]), "constant", 0.0)
|
||||||
assert distortion_params.shape[-1] == 8
|
assert distortion_params.shape[-1] == 8
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ Camera Models
|
|||||||
"""
|
"""
|
||||||
import base64
|
import base64
|
||||||
import math
|
import math
|
||||||
import os
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from enum import Enum, auto
|
from enum import Enum, auto
|
||||||
from typing import Dict, List, Optional, Tuple, Union
|
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.cameras.rays import RayBundle
|
||||||
from nerfstudio.data.scene_box import SceneBox
|
from nerfstudio.data.scene_box import SceneBox
|
||||||
from nerfstudio.utils import profiler
|
from nerfstudio.utils import profiler
|
||||||
from nerfstudio.utils.misc import strtobool
|
|
||||||
from nerfstudio.utils.tensor_dataclass import TensorDataclass
|
from nerfstudio.utils.tensor_dataclass import TensorDataclass
|
||||||
|
|
||||||
TORCH_DEVICE = Union[torch.device, str] # pylint: disable=invalid-name
|
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),
|
coord_stack[coord_mask, :].reshape(3, -1, 2),
|
||||||
distortion_params[mask, :],
|
distortion_params[mask, :],
|
||||||
).reshape(-1, 2)
|
).reshape(-1, 2)
|
||||||
except:
|
except ImportError:
|
||||||
coord_stack[coord_mask, :] = camera_utils.radial_and_tangential_undistort(
|
coord_stack[coord_mask, :] = camera_utils.radial_and_tangential_undistort(
|
||||||
coord_stack[coord_mask, :].reshape(3, -1, 2),
|
coord_stack[coord_mask, :].reshape(3, -1, 2),
|
||||||
distortion_params[mask, :],
|
distortion_params[mask, :],
|
||||||
@@ -670,12 +668,11 @@ class Cameras(TensorDataclass):
|
|||||||
if mask.any():
|
if mask.any():
|
||||||
if distortion_params_delta is not None:
|
if distortion_params_delta is not None:
|
||||||
raise NotImplementedError("Fisheye distortion optimization is not implemented")
|
raise NotImplementedError("Fisheye distortion optimization is not implemented")
|
||||||
else:
|
# use nerfacc which does not provide gradient
|
||||||
# use nerfacc with do not provide gradient
|
coord_stack[coord_mask, :] = opencv_lens_undistortion_fisheye(
|
||||||
coord_stack[coord_mask, :] = opencv_lens_undistortion_fisheye(
|
coord_stack[coord_mask, :].reshape(3, -1, 2),
|
||||||
coord_stack[coord_mask, :].reshape(3, -1, 2),
|
distortion_params[mask, :],
|
||||||
distortion_params[mask, :],
|
).reshape(-1, 2)
|
||||||
).reshape(-1, 2)
|
|
||||||
|
|
||||||
# Make sure after we have undistorted our images, the shapes are still correct
|
# Make sure after we have undistorted our images, the shapes are still correct
|
||||||
assert coord_stack.shape == (3,) + num_rays_shape + (2,)
|
assert coord_stack.shape == (3,) + num_rays_shape + (2,)
|
||||||
|
|||||||
@@ -548,14 +548,12 @@ class VanillaDataManager(DataManager): # pylint: disable=abstract-method
|
|||||||
def get_train_rays_per_batch(self) -> int:
|
def get_train_rays_per_batch(self) -> int:
|
||||||
if self.train_pixel_sampler is None:
|
if self.train_pixel_sampler is None:
|
||||||
return self.config.train_num_rays_per_batch
|
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:
|
def get_eval_rays_per_batch(self) -> int:
|
||||||
if self.eval_pixel_sampler is None:
|
if self.eval_pixel_sampler is None:
|
||||||
return self.config.eval_num_rays_per_batch
|
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:
|
def get_datapath(self) -> Path:
|
||||||
return self.config.dataparser.data
|
return self.config.dataparser.data
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import numpy as np
|
|||||||
import torch
|
import torch
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
|
|
||||||
from nerfstudio.cameras import camera_utils
|
|
||||||
from nerfstudio.cameras.cameras import Cameras, CameraType
|
from nerfstudio.cameras.cameras import Cameras, CameraType
|
||||||
from nerfstudio.data.dataparsers.base_dataparser import (
|
from nerfstudio.data.dataparsers.base_dataparser import (
|
||||||
DataParser,
|
DataParser,
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ Ray generator.
|
|||||||
"""
|
"""
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import torch
|
|
||||||
from torch import nn
|
from torch import nn
|
||||||
from torchtyping import TensorType
|
from torchtyping import TensorType
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class NerfplayerNGPModel(NGPModel):
|
|||||||
|
|
||||||
self.field = NerfplayerNGPField(
|
self.field = NerfplayerNGPField(
|
||||||
aabb=self.scene_box.aabb,
|
aabb=self.scene_box.aabb,
|
||||||
use_appearance_embedding=self.config.use_appearance_embedding,
|
use_appearance_embedding=False,
|
||||||
num_images=self.num_train_data,
|
num_images=self.num_train_data,
|
||||||
temporal_dim=self.config.temporal_dim,
|
temporal_dim=self.config.temporal_dim,
|
||||||
num_levels=self.config.num_levels,
|
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)
|
self.scene_aabb = Parameter(self.scene_box.aabb.flatten(), requires_grad=False)
|
||||||
|
|
||||||
# Occupancy Grid
|
# Occupancy Grid
|
||||||
grid_scale = 1 << (self.config.grid_levels - 1)
|
|
||||||
self.occupancy_grid = nerfacc.OccGridEstimator(
|
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,
|
resolution=self.config.grid_resolution,
|
||||||
levels=self.config.grid_levels,
|
levels=self.config.grid_levels,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user