mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-02 05:48:57 +08:00
Fixed friends dataset w/o caching (#365)
* fixing friends dataloading and nerfw running * put dataset back to normal
This commit is contained in:
1 parent
42711497ab
commit
512a51f714
11 files changed
+98
-170
No files matched your search
@@ -42,10 +42,10 @@ class InputDataset(Dataset):
|
||||
alpha_color (TensorType[3], optional): Sets transparent regions to specified color, otherwise black.
|
||||
"""
|
||||
super().__init__()
|
||||
self.inputs: DatasetInputs = config.setup().get_dataset_inputs(split=split)
|
||||
self.dataset_inputs: DatasetInputs = config.setup().get_dataset_inputs(split=split)
|
||||
|
||||
def __len__(self):
|
||||
return len(self.inputs.image_filenames)
|
||||
return len(self.dataset_inputs.image_filenames)
|
||||
|
||||
def get_numpy_image(self, image_idx: int) -> npt.NDArray[np.uint8]:
|
||||
"""Returns the image.
|
||||
@@ -56,7 +56,7 @@ class InputDataset(Dataset):
|
||||
Returns:
|
||||
np.uint8: an image of shape (H, W, 3 or 4)
|
||||
"""
|
||||
image_filename = self.inputs.image_filenames[image_idx]
|
||||
image_filename = self.dataset_inputs.image_filenames[image_idx]
|
||||
pil_image = Image.open(image_filename)
|
||||
image = np.array(pil_image, dtype="uint8") # shape is (h, w, 3 or 4)
|
||||
assert len(image.shape) == 3
|
||||
@@ -67,9 +67,9 @@ class InputDataset(Dataset):
|
||||
def get_image(self, image_idx: int) -> TensorType["image_height", "image_width", "num_channels"]:
|
||||
"""Returns a 3 channel image."""
|
||||
image = torch.from_numpy(self.get_numpy_image(image_idx).astype("float32") / 255.0)
|
||||
if self.inputs.alpha_color is not None and image.shape[-1] == 4:
|
||||
if self.dataset_inputs.alpha_color is not None and image.shape[-1] == 4:
|
||||
assert image.shape[-1] == 4
|
||||
image = image[:, :, :3] * image[:, :, -1:] + self.inputs.alpha_color * (1.0 - image[:, :, -1:])
|
||||
image = image[:, :, :3] * image[:, :, -1:] + self.dataset_inputs.alpha_color * (1.0 - image[:, :, -1:])
|
||||
else:
|
||||
image = image[:, :, :3]
|
||||
return image
|
||||
@@ -80,11 +80,11 @@ class InputDataset(Dataset):
|
||||
data = {"image_idx": image_idx}
|
||||
assert is_not_none(image)
|
||||
data["image"] = image
|
||||
for _, data_func_dict in self.inputs.additional_inputs.items():
|
||||
for _, data_func_dict in self.dataset_inputs.additional_inputs.items():
|
||||
assert "func" in data_func_dict, "Missing function to process data: specify `func` in `additional_inputs`"
|
||||
func = data_func_dict["func"]
|
||||
assert "data" in data_func_dict, "No data to process: specify `data` in `additional_inputs`"
|
||||
data.update(func(data_func_dict["data"]))
|
||||
data.update(func(data_func_dict["data"], image_idx))
|
||||
return data
|
||||
|
||||
def __getitem__(self, image_idx):
|
||||
|
||||
Reference in new issue
Block a user