4
0
mirror of https://github.com/nerfstudio-project/nerfstudio.git synced 2026-11-11 02:24:38 +08:00

adding patch_size back

This commit is contained in:
AdamRashid96 2023-08-02 00:37:46 +00:00
parent 8a1aaaa74f
commit ffb221a062
2 changed files with 8 additions and 1 deletions

View File

@ -57,6 +57,7 @@ from nerfstudio.data.datasets.base_dataset import InputDataset
from nerfstudio.data.pixel_samplers import (
PixelSampler,
PixelSamplerConfig,
PatchPixelSamplerConfig,
)
from nerfstudio.data.utils.dataloaders import (
CacheDataloader,
@ -345,6 +346,8 @@ class VanillaDataManagerConfig(DataManagerConfig):
"""The scale factor for scaling spatial data such as images, mask, semantics
along with relevant information about camera intrinsics
"""
patch_size: int = 1
"""Size of patch to sample from. If >1, patch-based sampling will be used."""
pixel_sampler: PixelSamplerConfig = PixelSamplerConfig()
"""Specifies the pixel sampler used to sample pixels from images."""
@ -458,6 +461,10 @@ class VanillaDataManager(DataManager, Generic[TDataset]):
def _get_pixel_sampler(self, dataset: TDataset, num_rays_per_batch: int) -> PixelSampler:
"""Infer pixel sampler to use."""
if self.config.patch_size > 1:
return PatchPixelSamplerConfig().setup(
patch_size=self.config.patch_size, num_rays_per_batch=num_rays_per_batch
)
is_equirectangular = (dataset.cameras.camera_type == CameraType.EQUIRECTANGULAR.value).all()
if is_equirectangular.any():
CONSOLE.print("[bold yellow]Warning: Some cameras are equirectangular, but using default pixel sampler.")

View File

@ -380,7 +380,7 @@ class PairPixelSampler(PixelSampler): # pylint: disable=too-few-public-methods
device: Union[torch.device, str] = "cpu",
) -> Int[Tensor, "batch_size 3"]:
if mask:
# Note: if there is a mask, should switch to the base PixelSampler class
# Note: if there is a mask, should switch to the base PixelSampler class
raise NotImplementedError()
else: