Files
nerfstudio/mattport/nerf/dataset/utils.py
T
Ethan Weber 676beebb14 Setting near and far with scene bounds collider. Also LR schedules. (#74)
* some initial cuda code as I learn. using git to save progress.

* first cuda kernel for ray sampling that mostly works

* cleaning up code. working on lr. structs for scene bounds aabb

* added scene bounds collider code

* updated setup

* setup

* setup

* black

* including some files

* exporting env variable

* new file

* git workflows

* github actions

* github actions

* github actions

* removing env var
2022-05-16 14:03:19 -07:00

64 lines
2.2 KiB
Python

"""
For loading the blender dataset format.
"""
from typing import Optional, Union
from omegaconf import ListConfig
from mattport.nerf.dataset.format.blender import load_blender_data
from mattport.nerf.dataset.format.friends import load_friends_data
from mattport.nerf.dataset.structs import DatasetInputs
from mattport.structures.colors import get_color
from mattport.utils.io import get_absolute_path
def get_dataset_inputs(
data_directory: str,
dataset_format: str,
split: str,
downscale_factor: int = 1,
alpha_color: Optional[Union[str, list, ListConfig]] = None,
load_dataset_inputs_from_cache: bool = False,
) -> DatasetInputs:
"""Returns the dataset inputs, which will be used with an ImageDataset and RayGenerator.
# TODO: implement the `test` split, which will have depths and normals, etc.
Args:
data_directory (str): Location of data
dataset_format (str): Name of dataset type
downscale_factor (int, optional): How much to downscale images. Defaults to 1.0.
alpha_color (str, list, optional): Sets transparent regions to specified color, otherwise black.
load_from_cache (bool)
Returns:
DatasetInputs: The inputs needed for generating rays.
"""
if load_dataset_inputs_from_cache:
print("Loading from cache.")
return None
if alpha_color is not None:
alpha_color = get_color(alpha_color)
if dataset_format == "blender":
dataset_inputs = load_blender_data(
get_absolute_path(data_directory),
downscale_factor=downscale_factor,
split=split,
alpha_color=alpha_color,
)
elif dataset_format == "friends":
# TODO(ethan): change this hack, and do proper splits for the friends dataset
# currently we assume that there is only the training set of images
dataset_inputs = load_friends_data(
get_absolute_path(data_directory),
downscale_factor=downscale_factor,
split="train",
include_point_cloud=False,
)
else:
raise NotImplementedError(f"{dataset_format} is not a valid dataset type")
return dataset_inputs