Revert "MinimalDataParser add options, allow Nerfstudio data format to specify test indices" (#1583)

Revert "MinimalDataParser add options, allow Nerfstudio data format to specify test indices (#1541)"

This reverts commit c61d3e9387.
This commit is contained in:
Matthew Tancik authored and GitHub committed 2023-03-10 10:23:17 -08:00
1 parent 21a452f1b4
commit 510188b1e6
5 files changed
+19 -158

No files matched your search

@@ -182,36 +182,22 @@ class Nerfstudio(DataParser):
You should check that depth_file_path is specified for every frame (or zero frames) in transforms.json.
"""
has_split_files_spec = any(f"{split}_filenames" in meta for split in ("train", "val", "test"))
if f"{split}_filenames" in meta:
# Validate split first
split_filenames = set(self._get_fname(PurePath(x), data_dir) for x in meta[f"{split}_filenames"])
unmatched_filenames = split_filenames.difference(image_filenames)
if unmatched_filenames:
raise RuntimeError(f"Some filenames for split {split} were not found: {unmatched_filenames}.")
indices = [i for i, path in enumerate(image_filenames) if path in split_filenames]
CONSOLE.log(f"[yellow] Dataset is overriding {split}_indices to {indices}")
indices = np.array(indices, dtype=np.int32)
elif has_split_files_spec:
raise RuntimeError(f"The dataset's list of filenames for split {split} is missing.")
# filter image_filenames and poses based on train/eval split percentage
num_images = len(image_filenames)
num_train_images = math.ceil(num_images * self.config.train_split_fraction)
num_eval_images = num_images - num_train_images
i_all = np.arange(num_images)
i_train = np.linspace(
0, num_images - 1, num_train_images, dtype=int
) # equally spaced training images starting and ending at 0 and num_images-1
i_eval = np.setdiff1d(i_all, i_train) # eval images are the remaining images
assert len(i_eval) == num_eval_images
if split == "train":
indices = i_train
elif split in ["val", "test"]:
indices = i_eval
else:
# filter image_filenames and poses based on train/eval split percentage
num_images = len(image_filenames)
num_train_images = math.ceil(num_images * self.config.train_split_fraction)
num_eval_images = num_images - num_train_images
i_all = np.arange(num_images)
i_train = np.linspace(
0, num_images - 1, num_train_images, dtype=int
) # equally spaced training images starting and ending at 0 and num_images-1
i_eval = np.setdiff1d(i_all, i_train) # eval images are the remaining images
assert len(i_eval) == num_eval_images
if split == "train":
indices = i_train
elif split in ["val", "test"]:
indices = i_eval
else:
raise ValueError(f"Unknown dataparser split {split}")
raise ValueError(f"Unknown dataparser split {split}")
if "orientation_override" in meta:
orientation_method = meta["orientation_override"]
@@ -288,15 +274,6 @@ class Nerfstudio(DataParser):
assert self.downscale_factor is not None
cameras.rescale_output_resolution(scaling_factor=1.0 / self.downscale_factor)
if "applied_transform" in meta:
applied_transform = np.array(meta["applied_transform"], dtype=np.float32)
transform_matrix = transform_matrix @ np.concatenate(
(applied_transform, np.array([0, 0, 0, 1], dtype=np.float32)), 0
)
if "applied_scale" in meta:
applied_scale = float(meta["applied_scale"])
scale_factor *= applied_scale
dataparser_outputs = DataparserOutputs(
image_filenames=image_filenames,
cameras=cameras,