mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-05 23:38:42 +08:00
Merge branch 'master' into Data-Refactoring
This commit is contained in:
55 files changed
+3295
-30047
No files matched your search
@@ -18,7 +18,8 @@ Data loader.
|
||||
|
||||
import random
|
||||
from abc import abstractmethod
|
||||
from typing import Dict, List, Tuple, Union
|
||||
from typing import Dict, List, Optional, Tuple, Union
|
||||
from omegaconf import ListConfig
|
||||
|
||||
import torch
|
||||
from omegaconf import ListConfig
|
||||
@@ -272,12 +273,20 @@ class FixedIndicesEvalDataloader(EvalDataloader):
|
||||
intrinsics,
|
||||
camera_to_world,
|
||||
num_rays_per_chunk: int,
|
||||
image_indices: Union[List[int], ListConfig],
|
||||
image_indices: Optional[Union[List[int], ListConfig]] = None,
|
||||
device="cpu",
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
Args:
|
||||
image_dataset: ImageDataset to load data from
|
||||
image_indices: List of image indices to load data from. If None, then use all images.
|
||||
"""
|
||||
super().__init__(image_dataset, intrinsics, camera_to_world, num_rays_per_chunk, device, **kwargs)
|
||||
self.image_indices = image_indices
|
||||
if image_indices is None:
|
||||
self.image_indices = list(range(len(image_dataset)))
|
||||
else:
|
||||
self.image_indices = image_indices
|
||||
self.num_rays_per_chunk = num_rays_per_chunk
|
||||
self.count = 0
|
||||
|
||||
|
||||
@@ -57,6 +57,12 @@ def load_instant_ngp_data(
|
||||
poses.append(np.array(frame["transform_matrix"]))
|
||||
if num_skipped_image_filenames >= 0:
|
||||
logging.info("Skipping %s files in dataset split %s.", num_skipped_image_filenames, split)
|
||||
assert (
|
||||
len(image_filenames) != 0
|
||||
), """
|
||||
No image files found.
|
||||
You should check the file_paths in the transforms.json file to make sure they are correct.
|
||||
"""
|
||||
poses = np.array(poses).astype(np.float32)
|
||||
poses[:3, 3] *= camera_translation_scalar
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ class ImageDataset(torch.utils.data.Dataset):
|
||||
def get_image(self, image_idx: int):
|
||||
"""Returns a 3 channel image."""
|
||||
image = torch.from_numpy(self.get_numpy_image(image_idx).astype("float32") / 255.0)
|
||||
if self.alpha_color is not None:
|
||||
if self.alpha_color is not None and image.shape[-1] == 4:
|
||||
assert image.shape[-1] == 4
|
||||
image = image[:, :, :3] * image[:, :, -1:] + self.alpha_color * (1.0 - image[:, :, -1:])
|
||||
else:
|
||||
|
||||
Reference in new issue
Block a user