Fix type errors (#296)

This commit is contained in:
Matthew Tancik authored and GitHub committed 2022-08-25 08:48:25 -07:00
1 parent 3963a1d9cb
commit 86ea6de059
5 files changed
+20 -7

No files matched your search

+1 -2
View File
@@ -26,7 +26,6 @@ from torch.nn.functional import normalize
from torchtyping import TensorType from torchtyping import TensorType
from nerfactory.cameras.rays import RayBundle from nerfactory.cameras.rays import RayBundle
from nerfactory.utils.misc import is_not_none
class Camera: class Camera:
@@ -315,7 +314,7 @@ class PinholeCamera(Camera):
"camera_to_world": self.camera_to_world.tolist(), "camera_to_world": self.camera_to_world.tolist(),
"camera_index": self.camera_index, "camera_index": self.camera_index,
} }
if is_not_none(image): if image is not None:
image_uint8 = (image * 255).detach().cpu().numpy().astype(np.uint8) image_uint8 = (image * 255).detach().cpu().numpy().astype(np.uint8)
if resize_shape: if resize_shape:
image_uint8 = cv2.resize(image_uint8, resize_shape) image_uint8 = cv2.resize(image_uint8, resize_shape)
+16 -3
View File
@@ -20,6 +20,7 @@ import random
from abc import abstractmethod from abc import abstractmethod
from typing import Dict, List, Optional, Tuple, Union from typing import Dict, List, Optional, Tuple, Union
import torch
from omegaconf import ListConfig from omegaconf import ListConfig
from nerfactory.cameras.cameras import Camera, get_camera from nerfactory.cameras.cameras import Camera, get_camera
@@ -32,7 +33,13 @@ class EvalDataloader: # pylint: disable=too-few-public-methods
"""Evaluation dataloader base class""" """Evaluation dataloader base class"""
def __init__( def __init__(
self, image_dataset: ImageDataset, intrinsics, camera_to_world, num_rays_per_chunk: int, device="cpu", **kwargs self,
image_dataset: ImageDataset,
intrinsics,
camera_to_world,
num_rays_per_chunk: int,
device: Union[torch.device, str] = "cpu",
**kwargs,
): ):
super().__init__() super().__init__()
self.image_dataset = image_dataset self.image_dataset = image_dataset
@@ -78,7 +85,7 @@ class FixedIndicesEvalDataloader(EvalDataloader):
camera_to_world, camera_to_world,
num_rays_per_chunk: int, num_rays_per_chunk: int,
image_indices: Optional[Union[List[int], ListConfig]] = None, image_indices: Optional[Union[List[int], ListConfig]] = None,
device="cpu", device: Union[torch.device, str] = "cpu",
**kwargs, **kwargs,
): ):
""" """
@@ -112,7 +119,13 @@ class RandIndicesEvalDataloader(EvalDataloader):
"""Dataloader that returns random images.""" """Dataloader that returns random images."""
def __init__( def __init__(
self, image_dataset: ImageDataset, intrinsics, camera_to_world, num_rays_per_chunk: int, device="cpu", **kwargs self,
image_dataset: ImageDataset,
intrinsics,
camera_to_world,
num_rays_per_chunk: int,
device: Union[torch.device, str] = "cpu",
**kwargs,
): ):
super().__init__(image_dataset, intrinsics, camera_to_world, num_rays_per_chunk, device, **kwargs) super().__init__(image_dataset, intrinsics, camera_to_world, num_rays_per_chunk, device, **kwargs)
self.count = 0 self.count = 0
@@ -77,7 +77,7 @@ class DensityGrid(nn.Module):
update_every_num_iters (int): How frequently to update the grid values. Defaults to 16. update_every_num_iters (int): How frequently to update the grid values. Defaults to 16.
""" """
density_grid: TensorType["num_cascades", "resolution**3"] density_grid: TensorType["num_cascades", "resolution_cubed"]
mean_density: TensorType[1] mean_density: TensorType[1]
def __init__( def __init__(
+1 -1
View File
@@ -118,7 +118,7 @@ class NerfWModel(Model):
def get_outputs(self, ray_bundle: RayBundle): def get_outputs(self, ray_bundle: RayBundle):
if misc.is_not_none(ray_bundle.camera_indices): if ray_bundle.camera_indices is not None:
# TODO(ethan): remove this check # TODO(ethan): remove this check
assert ( assert (
torch.max(ray_bundle.camera_indices) < self.num_images torch.max(ray_bundle.camera_indices) < self.num_images
+1
View File
@@ -58,6 +58,7 @@ defineConstant = { DEBUG = true }
reportMissingImports = true reportMissingImports = true
reportMissingTypeStubs = false reportMissingTypeStubs = false
reportPrivateImportUsage = false reportPrivateImportUsage = false
reportUndefinedVariable = false
pythonVersion = "3.8" pythonVersion = "3.8"
pythonPlatform = "Linux" pythonPlatform = "Linux"