fix linting

This commit is contained in:
Ruilong Li committed 2023-04-09 11:05:50 +00:00
1 parent b02f376f25
commit 97c411ea52
6 files changed
+12 -19

No files matched your search

+2 -1
View File
@@ -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
+6 -9
View File
@@ -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,)
@@ -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
@@ -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,
@@ -17,7 +17,6 @@ Ray generator.
"""
from typing import Optional
import torch
from torch import nn
from torchtyping import TensorType
+2 -3
View File
@@ -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,
)