mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-07 00:09:14 +08:00
dataset_inputs -> dataparser_outputs (#627)
This commit is contained in:
1 parent
ef5384afb3
commit
3efd3c3298
17 files changed
+52
-179
No files matched your search
@@ -50,7 +50,7 @@ class Semantics:
|
||||
|
||||
@dataclass
|
||||
class DataparserOutputs:
|
||||
"""Dataset inputs for the image dataset and the ray generator."""
|
||||
"""Dataparser outputs for the image dataset and the ray generator."""
|
||||
|
||||
image_filenames: List[Path]
|
||||
"""Filenames for the images."""
|
||||
@@ -64,7 +64,7 @@ class DataparserOutputs:
|
||||
additional_inputs: Dict[str, Any] = to_immutable_dict({})
|
||||
"""Dictionary of additional dataset information (e.g. semantics/point clouds/masks).
|
||||
{input_name:
|
||||
... {"func": function to process additional dataset inputs,
|
||||
... {"func": function to process additional dataparser outputs,
|
||||
... "kwargs": dictionary of data to pass into "func"}
|
||||
}
|
||||
"""
|
||||
@@ -97,24 +97,24 @@ class DataParser:
|
||||
self.config = config
|
||||
|
||||
@abstractmethod
|
||||
def _generate_dataset_inputs(self, split: str = "train") -> DataparserOutputs:
|
||||
"""Abstract method that returns the dataset inputs for the given split.
|
||||
def _generate_dataparser_outputs(self, split: str = "train") -> DataparserOutputs:
|
||||
"""Abstract method that returns the dataparser outputs for the given split.
|
||||
|
||||
Args:
|
||||
split: Which dataset split to generate (train/test).
|
||||
|
||||
Returns:
|
||||
DatasetInputs containing data for the specified dataset and split
|
||||
DataparserOutputs containing data for the specified dataset and split
|
||||
"""
|
||||
|
||||
def get_dataset_inputs(self, split: str = "train") -> DataparserOutputs:
|
||||
"""Returns the dataset inputs for the given split.
|
||||
def get_dataparser_outputs(self, split: str = "train") -> DataparserOutputs:
|
||||
"""Returns the dataparser outputs for the given split.
|
||||
|
||||
Args:
|
||||
split: Which dataset split to generate (train/test).
|
||||
|
||||
Returns:
|
||||
DatasetInputs containing data for the specified dataset and split
|
||||
DataparserOutputs containing data for the specified dataset and split
|
||||
"""
|
||||
dataset_inputs = self._generate_dataset_inputs(split)
|
||||
return dataset_inputs
|
||||
dataparser_outputs = self._generate_dataparser_outputs(split)
|
||||
return dataparser_outputs
|
||||
@@ -62,7 +62,7 @@ class Blender(DataParser):
|
||||
self.scale_factor: float = config.scale_factor
|
||||
self.alpha_color = config.alpha_color
|
||||
|
||||
def _generate_dataset_inputs(self, split="train"):
|
||||
def _generate_dataparser_outputs(self, split="train"):
|
||||
if self.alpha_color is not None:
|
||||
alpha_color_tensor = get_color(self.alpha_color)
|
||||
else:
|
||||
@@ -99,11 +99,11 @@ class Blender(DataParser):
|
||||
camera_type=CameraType.PERSPECTIVE,
|
||||
)
|
||||
|
||||
dataset_inputs = DataparserOutputs(
|
||||
dataparser_outputs = DataparserOutputs(
|
||||
image_filenames=image_filenames,
|
||||
cameras=cameras,
|
||||
alpha_color=alpha_color_tensor,
|
||||
scene_box=scene_box,
|
||||
)
|
||||
|
||||
return dataset_inputs
|
||||
return dataparser_outputs
|
||||
@@ -81,7 +81,7 @@ class Friends(DataParser):
|
||||
|
||||
config: FriendsDataParserConfig
|
||||
|
||||
def _generate_dataset_inputs(self, split="train"): # pylint: disable=unused-argument,too-many-statements
|
||||
def _generate_dataparser_outputs(self, split="train"): # pylint: disable=unused-argument,too-many-statements
|
||||
|
||||
cameras_json = load_from_json(self.config.data_directory / "cameras.json")
|
||||
frames = cameras_json["frames"]
|
||||
@@ -182,10 +182,10 @@ class Friends(DataParser):
|
||||
)
|
||||
cameras.rescale_output_resolution(scaling_factor=1.0 / self.config.downscale_factor)
|
||||
|
||||
dataset_inputs = DataparserOutputs(
|
||||
dataparser_outputs = DataparserOutputs(
|
||||
image_filenames=image_filenames,
|
||||
cameras=cameras,
|
||||
scene_box=scene_box,
|
||||
additional_inputs={"semantics": {"func": get_semantics_and_masks, "kwargs": {"semantics": semantics}}},
|
||||
)
|
||||
return dataset_inputs
|
||||
return dataparser_outputs
|
||||
@@ -55,7 +55,7 @@ class InstantNGP(DataParser):
|
||||
|
||||
config: InstantNGPDataParserConfig
|
||||
|
||||
def _generate_dataset_inputs(self, split="train"):
|
||||
def _generate_dataparser_outputs(self, split="train"):
|
||||
|
||||
meta = load_from_json(self.config.data_directory / "transforms.json")
|
||||
image_filenames = []
|
||||
@@ -107,10 +107,10 @@ class InstantNGP(DataParser):
|
||||
)
|
||||
|
||||
# TODO(ethan): add alpha background color
|
||||
dataset_inputs = DataparserOutputs(
|
||||
dataparser_outputs = DataparserOutputs(
|
||||
image_filenames=image_filenames,
|
||||
cameras=cameras,
|
||||
scene_box=scene_box,
|
||||
)
|
||||
|
||||
return dataset_inputs
|
||||
return dataparser_outputs
|
||||
@@ -78,7 +78,7 @@ class Mipnerf360(DataParser):
|
||||
poses_orig[:, :3, :4] = poses[:, :3, :4]
|
||||
return poses_orig
|
||||
|
||||
def _generate_dataset_inputs(self, split="train"):
|
||||
def _generate_dataparser_outputs(self, split="train"):
|
||||
image_dir = "images"
|
||||
if self.config.downscale_factor > 1:
|
||||
image_dir += f"_{self.config.downscale_factor}"
|
||||
@@ -155,10 +155,10 @@ class Mipnerf360(DataParser):
|
||||
|
||||
cameras.rescale_output_resolution(scaling_factor=1.0 / self.config.downscale_factor)
|
||||
|
||||
dataset_inputs = DataparserOutputs(
|
||||
dataparser_outputs = DataparserOutputs(
|
||||
image_filenames=image_filenames,
|
||||
cameras=cameras,
|
||||
scene_box=scene_box,
|
||||
)
|
||||
|
||||
return dataset_inputs
|
||||
return dataparser_outputs
|
||||
@@ -62,7 +62,7 @@ class Nerfstudio(DataParser):
|
||||
|
||||
config: NerfstudioDataParserConfig
|
||||
|
||||
def _generate_dataset_inputs(self, split="train"):
|
||||
def _generate_dataparser_outputs(self, split="train"):
|
||||
# pylint: disable=too-many-statements
|
||||
|
||||
meta = load_from_json(self.config.data_directory / "transforms.json")
|
||||
@@ -157,9 +157,9 @@ class Nerfstudio(DataParser):
|
||||
|
||||
cameras.rescale_output_resolution(scaling_factor=1.0 / self.config.downscale_factor)
|
||||
|
||||
dataset_inputs = DataparserOutputs(
|
||||
dataparser_outputs = DataparserOutputs(
|
||||
image_filenames=image_filenames,
|
||||
cameras=cameras,
|
||||
scene_box=scene_box,
|
||||
)
|
||||
return dataset_inputs
|
||||
return dataparser_outputs
|
||||
@@ -60,7 +60,7 @@ class Record3D(DataParser):
|
||||
|
||||
config: Record3DDataParserConfig
|
||||
|
||||
def _generate_dataset_inputs(self, split: str = "train") -> DataparserOutputs:
|
||||
def _generate_dataparser_outputs(self, split: str = "train") -> DataparserOutputs:
|
||||
image_dir = self.config.data_directory / "rgb"
|
||||
|
||||
if not image_dir.exists():
|
||||
@@ -144,10 +144,10 @@ class Record3D(DataParser):
|
||||
camera_type=CameraType.PERSPECTIVE,
|
||||
)
|
||||
|
||||
dataset_inputs = DataparserOutputs(
|
||||
dataparser_outputs = DataparserOutputs(
|
||||
image_filenames=image_filenames,
|
||||
cameras=cameras,
|
||||
scene_box=scene_box,
|
||||
)
|
||||
|
||||
return dataset_inputs
|
||||
return dataparser_outputs
|
||||
Reference in new issue
Block a user