mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-20 22:56:03 +08:00
1 parent
5be513e968
commit
66cd6817f9
29 files changed
+92
-92
No files matched your search
@@ -205,9 +205,9 @@ class Cameras(TensorDataclass):
|
||||
elif isinstance(camera_type, int):
|
||||
camera_type = torch.tensor([camera_type], device=self.device)
|
||||
elif isinstance(camera_type, torch.Tensor):
|
||||
assert not torch.is_floating_point(
|
||||
camera_type
|
||||
), f"camera_type tensor must be of type int, not: {camera_type.dtype}"
|
||||
assert not torch.is_floating_point(camera_type), (
|
||||
f"camera_type tensor must be of type int, not: {camera_type.dtype}"
|
||||
)
|
||||
camera_type = camera_type.to(self.device)
|
||||
if camera_type.ndim == 0 or camera_type.shape[-1] != 1:
|
||||
camera_type = camera_type.unsqueeze(-1)
|
||||
@@ -400,14 +400,14 @@ class Cameras(TensorDataclass):
|
||||
|
||||
# If the camera indices are an int, then we need to make sure that the camera batch is 1D
|
||||
if isinstance(camera_indices, int):
|
||||
assert (
|
||||
len(cameras.shape) == 1
|
||||
), "camera_indices must be a tensor if cameras are batched with more than 1 batch dimension"
|
||||
assert len(cameras.shape) == 1, (
|
||||
"camera_indices must be a tensor if cameras are batched with more than 1 batch dimension"
|
||||
)
|
||||
camera_indices = torch.tensor([camera_indices], device=cameras.device)
|
||||
|
||||
assert camera_indices.shape[-1] == len(
|
||||
cameras.shape
|
||||
), "camera_indices must have shape (num_rays:..., num_cameras_batch_dims)"
|
||||
assert camera_indices.shape[-1] == len(cameras.shape), (
|
||||
"camera_indices must have shape (num_rays:..., num_cameras_batch_dims)"
|
||||
)
|
||||
|
||||
# If keep_shape is True, then we need to make sure that the camera indices in question
|
||||
# are all the same height and width and can actually be batched while maintaining the image
|
||||
|
||||
@@ -205,8 +205,8 @@ class FullImageDatamanager(DataManager, Generic[TDataset]):
|
||||
data = dataset.get_data(idx, image_type=self.config.cache_images_type)
|
||||
camera = dataset.cameras[idx].reshape(())
|
||||
assert data["image"].shape[1] == camera.width.item() and data["image"].shape[0] == camera.height.item(), (
|
||||
f'The size of image ({data["image"].shape[1]}, {data["image"].shape[0]}) loaded '
|
||||
f'does not match the camera parameters ({camera.width.item(), camera.height.item()})'
|
||||
f"The size of image ({data['image'].shape[1]}, {data['image'].shape[0]}) loaded "
|
||||
f"does not match the camera parameters ({camera.width.item(), camera.height.item()})"
|
||||
)
|
||||
if camera.distortion_params is None or torch.all(camera.distortion_params == 0):
|
||||
return data
|
||||
|
||||
@@ -47,7 +47,7 @@ def downscale(img, scale: int) -> np.ndarray:
|
||||
return img
|
||||
height, width = img.shape[:2]
|
||||
if height % scale > 0 or width % scale > 0:
|
||||
raise ValueError(f"Image shape ({height},{width}) must be divisible by the" f" scale ({scale}).")
|
||||
raise ValueError(f"Image shape ({height},{width}) must be divisible by the scale ({scale}).")
|
||||
out_height, out_width = height // scale, width // scale
|
||||
resized = cv2.resize(img, (out_width, out_height), cv2.INTER_AREA) # type: ignore
|
||||
return resized
|
||||
|
||||
@@ -476,7 +476,7 @@ class Nerfstudio(DataParser):
|
||||
while True:
|
||||
if (max_res / 2 ** (df)) <= MAX_AUTO_RESOLUTION:
|
||||
break
|
||||
if not (data_dir / f"{downsample_folder_prefix}{2**(df+1)}" / filepath.name).exists():
|
||||
if not (data_dir / f"{downsample_folder_prefix}{2 ** (df + 1)}" / filepath.name).exists():
|
||||
break
|
||||
df += 1
|
||||
|
||||
|
||||
@@ -91,9 +91,9 @@ class NuScenes(DataParser):
|
||||
)
|
||||
cameras = ["CAM_" + camera for camera in self.config.cameras]
|
||||
|
||||
assert (
|
||||
len(cameras) == 1
|
||||
), "waiting on multiple camera support" # TODO: remove once multiple cameras are supported
|
||||
assert len(cameras) == 1, (
|
||||
"waiting on multiple camera support"
|
||||
) # TODO: remove once multiple cameras are supported
|
||||
|
||||
# get samples for scene
|
||||
samples = [
|
||||
|
||||
@@ -128,9 +128,9 @@ class InputDataset(Dataset):
|
||||
if self._dataparser_outputs.mask_filenames is not None:
|
||||
mask_filepath = self._dataparser_outputs.mask_filenames[image_idx]
|
||||
data["mask"] = get_image_mask_tensor_from_path(filepath=mask_filepath, scale_factor=self.scale_factor)
|
||||
assert (
|
||||
data["mask"].shape[:2] == data["image"].shape[:2]
|
||||
), f"Mask and image have different shapes. Got {data['mask'].shape[:2]} and {data['image'].shape[:2]}"
|
||||
assert data["mask"].shape[:2] == data["image"].shape[:2], (
|
||||
f"Mask and image have different shapes. Got {data['mask'].shape[:2]} and {data['image'].shape[:2]}"
|
||||
)
|
||||
if self.mask_color:
|
||||
data["image"] = torch.where(
|
||||
data["mask"] == 1.0, data["image"], torch.ones_like(data["image"]) * torch.tensor(self.mask_color)
|
||||
|
||||
@@ -556,9 +556,9 @@ class PairPixelSampler(PixelSampler): # pylint: disable=too-few-public-methods
|
||||
) -> Int[Tensor, "batch_size 3"]:
|
||||
rays_to_sample = self.rays_to_sample
|
||||
if batch_size is not None:
|
||||
assert (
|
||||
int(batch_size) % 2 == 0
|
||||
), f"PairPixelSampler can only return batch sizes in multiples of two (got {batch_size})"
|
||||
assert int(batch_size) % 2 == 0, (
|
||||
f"PairPixelSampler can only return batch sizes in multiples of two (got {batch_size})"
|
||||
)
|
||||
rays_to_sample = batch_size // 2
|
||||
|
||||
if isinstance(mask, Tensor) and not self.config.ignore_mask:
|
||||
|
||||
@@ -27,7 +27,7 @@ import torch.utils.data
|
||||
from nerfstudio.cameras.cameras import Cameras
|
||||
|
||||
NERFSTUDIO_COLLATE_ERR_MSG_FORMAT = (
|
||||
"default_collate: batch must contain tensors, numpy arrays, numbers, " "dicts, lists or anything in {}; found {}"
|
||||
"default_collate: batch must contain tensors, numpy arrays, numbers, dicts, lists or anything in {}; found {}"
|
||||
)
|
||||
np_str_obj_array_pattern = re.compile(r"[SaUO]")
|
||||
|
||||
@@ -152,14 +152,16 @@ def nerfstudio_collate(batch: Any, extra_mappings: Union[Dict[type, Callable], N
|
||||
assert all((isinstance(cam, Cameras) for cam in batch))
|
||||
assert all((cam.distortion_params is None for cam in batch)) or all(
|
||||
(cam.distortion_params is not None for cam in batch)
|
||||
), "All cameras must have distortion parameters or none of them should have distortion parameters.\
|
||||
), (
|
||||
"All cameras must have distortion parameters or none of them should have distortion parameters.\
|
||||
Generalized batching will be supported in the future."
|
||||
)
|
||||
|
||||
if batch[0].metadata is not None:
|
||||
metadata_keys = batch[0].metadata.keys()
|
||||
assert all(
|
||||
(cam.metadata.keys() == metadata_keys for cam in batch)
|
||||
), "All cameras must have the same metadata keys."
|
||||
assert all((cam.metadata.keys() == metadata_keys for cam in batch)), (
|
||||
"All cameras must have the same metadata keys."
|
||||
)
|
||||
else:
|
||||
assert all((cam.metadata is None for cam in batch)), "All cameras must have the same metadata keys."
|
||||
|
||||
|
||||
@@ -80,9 +80,9 @@ class TrainingCallback:
|
||||
args: Optional[List] = None,
|
||||
kwargs: Optional[Dict] = None,
|
||||
):
|
||||
assert (
|
||||
"step" in signature(func).parameters.keys()
|
||||
), f"'step: int' must be an argument in the callback function 'func': {func.__name__}"
|
||||
assert "step" in signature(func).parameters.keys(), (
|
||||
f"'step: int' must be an argument in the callback function 'func': {func.__name__}"
|
||||
)
|
||||
self.where_to_run = where_to_run
|
||||
self.update_every_num_iters = update_every_num_iters
|
||||
self.iters = iters
|
||||
|
||||
@@ -148,9 +148,9 @@ def generate_point_cloud(
|
||||
CONSOLE.print(f"Please set --normal_output_name to one of: {outputs.keys()}", justify="center")
|
||||
sys.exit(1)
|
||||
normal = outputs[normal_output_name]
|
||||
assert (
|
||||
torch.min(normal) >= 0.0 and torch.max(normal) <= 1.0
|
||||
), "Normal values from method output must be in [0, 1]"
|
||||
assert torch.min(normal) >= 0.0 and torch.max(normal) <= 1.0, (
|
||||
"Normal values from method output must be in [0, 1]"
|
||||
)
|
||||
normal = (normal * 2.0) - 1.0
|
||||
point = ray_bundle.origins + ray_bundle.directions * depth
|
||||
view_direction = ray_bundle.directions
|
||||
|
||||
@@ -369,9 +369,9 @@ class HashEncoding(Encoding):
|
||||
)
|
||||
|
||||
if self.tcnn_encoding is None:
|
||||
assert (
|
||||
interpolation is None or interpolation == "Linear"
|
||||
), f"interpolation '{interpolation}' is not supported for torch encoding backend"
|
||||
assert interpolation is None or interpolation == "Linear", (
|
||||
f"interpolation '{interpolation}' is not supported for torch encoding backend"
|
||||
)
|
||||
|
||||
def build_nn_modules(self) -> None:
|
||||
"""Initialize the torch version of the hash encoding."""
|
||||
|
||||
@@ -85,9 +85,9 @@ class Field(nn.Module):
|
||||
"""
|
||||
assert self._sample_locations is not None, "Sample locations must be set before calling get_normals."
|
||||
assert self._density_before_activation is not None, "Density must be set before calling get_normals."
|
||||
assert (
|
||||
self._sample_locations.shape[:-1] == self._density_before_activation.shape[:-1]
|
||||
), "Sample locations and density must have the same shape besides the last dimension."
|
||||
assert self._sample_locations.shape[:-1] == self._density_before_activation.shape[:-1], (
|
||||
"Sample locations and density must have the same shape besides the last dimension."
|
||||
)
|
||||
|
||||
normals = torch.autograd.grad(
|
||||
self._density_before_activation,
|
||||
|
||||
@@ -330,9 +330,9 @@ class PDFSampler(Sampler):
|
||||
u = u.expand(size=(*cdf.shape[:-1], num_bins))
|
||||
u = u.contiguous()
|
||||
|
||||
assert (
|
||||
ray_samples.spacing_starts is not None and ray_samples.spacing_ends is not None
|
||||
), "ray_sample spacing_starts and spacing_ends must be provided"
|
||||
assert ray_samples.spacing_starts is not None and ray_samples.spacing_ends is not None, (
|
||||
"ray_sample spacing_starts and spacing_ends must be provided"
|
||||
)
|
||||
assert ray_samples.spacing_to_euclidean_fn is not None, "ray_samples.spacing_to_euclidean_fn must be provided"
|
||||
existing_bins = torch.cat(
|
||||
[
|
||||
|
||||
@@ -193,9 +193,9 @@ class SurfaceModel(Model):
|
||||
Returns:
|
||||
Outputs of model. (ie. rendered colors)
|
||||
"""
|
||||
assert (
|
||||
ray_bundle.metadata is not None and "directions_norm" in ray_bundle.metadata
|
||||
), "directions_norm is required in ray_bundle.metadata"
|
||||
assert ray_bundle.metadata is not None and "directions_norm" in ray_bundle.metadata, (
|
||||
"directions_norm is required in ray_bundle.metadata"
|
||||
)
|
||||
|
||||
samples_and_field_outputs = self.sample_and_forward_field(ray_bundle=ray_bundle)
|
||||
|
||||
|
||||
@@ -327,9 +327,9 @@ class TensoRFModel(Model):
|
||||
elif self.config.regularization == "tv":
|
||||
density_plane_coef = self.field.density_encoding.plane_coef
|
||||
color_plane_coef = self.field.color_encoding.plane_coef
|
||||
assert isinstance(color_plane_coef, torch.Tensor) and isinstance(
|
||||
density_plane_coef, torch.Tensor
|
||||
), "TV reg only supported for TensoRF encoding types with plane_coef attribute"
|
||||
assert isinstance(color_plane_coef, torch.Tensor) and isinstance(density_plane_coef, torch.Tensor), (
|
||||
"TV reg only supported for TensoRF encoding types with plane_coef attribute"
|
||||
)
|
||||
loss_dict["tv_reg_density"] = tv_loss(density_plane_coef)
|
||||
loss_dict["tv_reg_color"] = tv_loss(color_plane_coef)
|
||||
elif self.config.regularization == "none":
|
||||
|
||||
@@ -422,9 +422,9 @@ class VanillaPipeline(Pipeline):
|
||||
self, step: Optional[int] = None, output_path: Optional[Path] = None, get_std: bool = False
|
||||
):
|
||||
"""Get the average metrics for evaluation images."""
|
||||
assert hasattr(
|
||||
self.datamanager, "fixed_indices_eval_dataloader"
|
||||
), "datamanager must have 'fixed_indices_eval_dataloader' attribute"
|
||||
assert hasattr(self.datamanager, "fixed_indices_eval_dataloader"), (
|
||||
"datamanager must have 'fixed_indices_eval_dataloader' attribute"
|
||||
)
|
||||
image_prefix = "eval"
|
||||
return self.get_average_image_metrics(
|
||||
self.datamanager.fixed_indices_eval_dataloader, image_prefix, step, output_path, get_std
|
||||
|
||||
@@ -54,9 +54,9 @@ class DynamicBatchPipeline(VanillaPipeline):
|
||||
grad_scaler: Optional[GradScaler] = None,
|
||||
):
|
||||
super().__init__(config, device, test_mode, world_size, local_rank)
|
||||
assert isinstance(
|
||||
self.datamanager, VanillaDataManager
|
||||
), "DynamicBatchPipeline only works with VanillaDataManager."
|
||||
assert isinstance(self.datamanager, VanillaDataManager), (
|
||||
"DynamicBatchPipeline only works with VanillaDataManager."
|
||||
)
|
||||
|
||||
self.dynamic_num_rays_per_batch = self.config.target_num_samples // self.config.max_num_samples_per_ray
|
||||
self._update_pixel_samplers()
|
||||
|
||||
@@ -145,9 +145,7 @@ class ColmapConverterToNerfstudioDataset(BaseConverterToNerfstudioDataset):
|
||||
summary_log.append(colmap_utils.get_matching_summary(num_frames, num_matched_frames))
|
||||
|
||||
else:
|
||||
CONSOLE.log(
|
||||
"[bold yellow]Warning: Could not find existing COLMAP results. " "Not generating transforms.json"
|
||||
)
|
||||
CONSOLE.log("[bold yellow]Warning: Could not find existing COLMAP results. Not generating transforms.json")
|
||||
return summary_log
|
||||
|
||||
def _export_depth(self) -> Tuple[Optional[Dict[int, Path]], List[str]]:
|
||||
@@ -224,7 +222,7 @@ class ColmapConverterToNerfstudioDataset(BaseConverterToNerfstudioDataset):
|
||||
)
|
||||
elif sfm_tool == "hloc":
|
||||
if mask_path is not None:
|
||||
raise RuntimeError("Cannot use a mask with hloc. Please remove the cropping options " "and try again.")
|
||||
raise RuntimeError("Cannot use a mask with hloc. Please remove the cropping options and try again.")
|
||||
|
||||
assert feature_type is not None
|
||||
assert matcher_type is not None
|
||||
@@ -241,7 +239,7 @@ class ColmapConverterToNerfstudioDataset(BaseConverterToNerfstudioDataset):
|
||||
use_single_camera_mode=self.use_single_camera_mode,
|
||||
)
|
||||
else:
|
||||
raise RuntimeError("Invalid combination of sfm_tool, feature_type, and matcher_type, " "exiting")
|
||||
raise RuntimeError("Invalid combination of sfm_tool, feature_type, and matcher_type, exiting")
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
super().__post_init__()
|
||||
|
||||
@@ -70,9 +70,9 @@ def polycam_to_json(
|
||||
frame["cy"] = frame_json["cy"] - crop_border_pixels
|
||||
frame["w"] = frame_json["width"] - crop_border_pixels * 2
|
||||
frame["h"] = frame_json["height"] - crop_border_pixels * 2
|
||||
frame["file_path"] = f"./images/frame_{i+1:05d}{image_filename.suffix}"
|
||||
frame["file_path"] = f"./images/frame_{i + 1:05d}{image_filename.suffix}"
|
||||
if use_depth:
|
||||
frame["depth_file_path"] = f"./depth/frame_{i+1:05d}{depth_filenames[i].suffix}"
|
||||
frame["depth_file_path"] = f"./depth/frame_{i + 1:05d}{depth_filenames[i].suffix}"
|
||||
# Transform matrix to nerfstudio format. Please refer to the documentation for coordinate system conventions.
|
||||
frame["transform_matrix"] = [
|
||||
[frame_json["t_20"], frame_json["t_21"], frame_json["t_22"], frame_json["t_23"]],
|
||||
|
||||
@@ -318,7 +318,7 @@ def copy_images_list(
|
||||
|
||||
crop_cmd = ""
|
||||
if crop_border_pixels is not None:
|
||||
crop_cmd = f"crop=iw-{crop_border_pixels*2}:ih-{crop_border_pixels*2}[cropped];[cropped]"
|
||||
crop_cmd = f"crop=iw-{crop_border_pixels * 2}:ih-{crop_border_pixels * 2}[cropped];[cropped]"
|
||||
elif crop_factor != (0.0, 0.0, 0.0, 0.0):
|
||||
height = 1 - crop_factor[0] - crop_factor[1]
|
||||
width = 1 - crop_factor[2] - crop_factor[3]
|
||||
@@ -484,7 +484,7 @@ def downscale_images(
|
||||
run_command(ffmpeg_cmd, verbose=verbose)
|
||||
|
||||
CONSOLE.log("[bold green]:tada: Done downscaling images.")
|
||||
downscale_text = [f"[bold blue]{2**(i+1)}x[/bold blue]" for i in range(num_downscales)]
|
||||
downscale_text = [f"[bold blue]{2 ** (i + 1)}x[/bold blue]" for i in range(num_downscales)]
|
||||
downscale_text = ", ".join(downscale_text[:-1]) + " and " + downscale_text[-1]
|
||||
return f"We downsampled the images by {downscale_text}"
|
||||
|
||||
|
||||
@@ -289,9 +289,9 @@ class PhototourismDownload(DatasetDownload):
|
||||
PhototourismDownload(capture_name=capture_name).download(save_dir)
|
||||
return
|
||||
|
||||
assert (
|
||||
self.capture_name in phototourism_downloads
|
||||
), f"Capture name {self.capture_name} not found in {phototourism_downloads.keys()}"
|
||||
assert self.capture_name in phototourism_downloads, (
|
||||
f"Capture name {self.capture_name} not found in {phototourism_downloads.keys()}"
|
||||
)
|
||||
url = phototourism_downloads[self.capture_name]
|
||||
target_path = str(save_dir / "phototourism" / self.capture_name)
|
||||
os.makedirs(target_path, exist_ok=True)
|
||||
@@ -350,9 +350,9 @@ class SDFstudioDemoDownload(DatasetDownload):
|
||||
SDFstudioDemoDownload(dataset_name=dataset_name).download(save_dir)
|
||||
return
|
||||
|
||||
assert (
|
||||
self.dataset_name in sdfstudio_downloads
|
||||
), f"Capture name {self.dataset_name} not found in {sdfstudio_downloads.keys()}"
|
||||
assert self.dataset_name in sdfstudio_downloads, (
|
||||
f"Capture name {self.dataset_name} not found in {sdfstudio_downloads.keys()}"
|
||||
)
|
||||
|
||||
url = sdfstudio_downloads[self.dataset_name]
|
||||
|
||||
@@ -421,9 +421,9 @@ class NeRFOSRDownload(DatasetDownload):
|
||||
NeRFOSRDownload(capture_name=capture_name).download(save_dir)
|
||||
return
|
||||
|
||||
assert (
|
||||
self.capture_name in nerfosr_downloads
|
||||
), f"Capture name {self.capture_name} not found in {nerfosr_downloads.keys()}"
|
||||
assert self.capture_name in nerfosr_downloads, (
|
||||
f"Capture name {self.capture_name} not found in {nerfosr_downloads.keys()}"
|
||||
)
|
||||
url = nerfosr_downloads[self.capture_name]
|
||||
target_path = str(save_dir / "nerfosr" / self.capture_name)
|
||||
os.makedirs(target_path, exist_ok=True)
|
||||
@@ -475,9 +475,9 @@ class Mill19Download(DatasetDownload):
|
||||
Mill19Download(capture_name=capture_name).download(save_dir)
|
||||
return
|
||||
|
||||
assert (
|
||||
self.capture_name in mill19_downloads
|
||||
), f"Capture name {self.capture_name} not found in {mill19_downloads.keys()}"
|
||||
assert self.capture_name in mill19_downloads, (
|
||||
f"Capture name {self.capture_name} not found in {mill19_downloads.keys()}"
|
||||
)
|
||||
url = mill19_downloads[self.capture_name]
|
||||
target_path = save_dir / "mill19" / self.capture_name
|
||||
target_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@@ -360,7 +360,7 @@ class EyefulTowerDownload(DatasetDownload):
|
||||
+ includes
|
||||
+ [base_url, str(output_path)]
|
||||
)
|
||||
CONSOLE.print(f"[EyefulTower Capture {i+1: >2d}/{len(captures)}]: '{capture}'")
|
||||
CONSOLE.print(f"[EyefulTower Capture {i + 1: >2d}/{len(captures)}]: '{capture}'")
|
||||
print(
|
||||
f"\tDownloading resolutions {resolutions}",
|
||||
f"to '{output_path.resolve()}' with command `aws {' '.join(command)}` ...",
|
||||
|
||||
@@ -556,9 +556,9 @@ class RenderCameraPath(BaseRender):
|
||||
self.output_path = Path(str(left_eye_path.parent)[:-5])
|
||||
self.output_path.mkdir(parents=True, exist_ok=True)
|
||||
if self.image_format == "png":
|
||||
ffmpeg_ods_command = f'ffmpeg -y -pattern_type glob -i "{str(left_eye_path.with_suffix("") / "*.png")}" -pattern_type glob -i "{str(right_eye_path.with_suffix("") / "*.png")}" -filter_complex vstack -start_number 0 "{str(self.output_path)+"//%05d.png"}"'
|
||||
ffmpeg_ods_command = f'ffmpeg -y -pattern_type glob -i "{str(left_eye_path.with_suffix("") / "*.png")}" -pattern_type glob -i "{str(right_eye_path.with_suffix("") / "*.png")}" -filter_complex vstack -start_number 0 "{str(self.output_path) + "//%05d.png"}"'
|
||||
elif self.image_format == "jpeg":
|
||||
ffmpeg_ods_command = f'ffmpeg -y -pattern_type glob -i "{str(left_eye_path.with_suffix("") / "*.jpg")}" -pattern_type glob -i "{str(right_eye_path.with_suffix("") / "*.jpg")}" -filter_complex vstack -start_number 0 "{str(self.output_path)+"//%05d.jpg"}"'
|
||||
ffmpeg_ods_command = f'ffmpeg -y -pattern_type glob -i "{str(left_eye_path.with_suffix("") / "*.jpg")}" -pattern_type glob -i "{str(right_eye_path.with_suffix("") / "*.jpg")}" -filter_complex vstack -start_number 0 "{str(self.output_path) + "//%05d.jpg"}"'
|
||||
run_command(ffmpeg_ods_command, verbose=False)
|
||||
|
||||
# remove the temp files directory
|
||||
@@ -577,9 +577,9 @@ class RenderCameraPath(BaseRender):
|
||||
self.output_path = Path(str(left_eye_path.parent)[:-5])
|
||||
self.output_path.mkdir(parents=True, exist_ok=True)
|
||||
if self.image_format == "png":
|
||||
ffmpeg_vr180_command = f'ffmpeg -y -pattern_type glob -i "{str(left_eye_path.with_suffix("") / "*.png")}" -pattern_type glob -i "{str(right_eye_path.with_suffix("") / "*.png")}" -filter_complex hstack -start_number 0 "{str(self.output_path)+"//%05d.png"}"'
|
||||
ffmpeg_vr180_command = f'ffmpeg -y -pattern_type glob -i "{str(left_eye_path.with_suffix("") / "*.png")}" -pattern_type glob -i "{str(right_eye_path.with_suffix("") / "*.png")}" -filter_complex hstack -start_number 0 "{str(self.output_path) + "//%05d.png"}"'
|
||||
elif self.image_format == "jpeg":
|
||||
ffmpeg_vr180_command = f'ffmpeg -y -pattern_type glob -i "{str(left_eye_path.with_suffix("") / "*.jpg")}" -pattern_type glob -i "{str(right_eye_path.with_suffix("") / "*.jpg")}" -filter_complex hstack -start_number 0 "{str(self.output_path)+"//%05d.jpg"}"'
|
||||
ffmpeg_vr180_command = f'ffmpeg -y -pattern_type glob -i "{str(left_eye_path.with_suffix("") / "*.jpg")}" -pattern_type glob -i "{str(right_eye_path.with_suffix("") / "*.jpg")}" -filter_complex hstack -start_number 0 "{str(self.output_path) + "//%05d.jpg"}"'
|
||||
run_command(ffmpeg_vr180_command, verbose=False)
|
||||
|
||||
# remove the temp files directory
|
||||
|
||||
@@ -42,9 +42,9 @@ def get_local_rank() -> int:
|
||||
"""The rank of the current process within the local (per-machine) process group."""
|
||||
if not is_dist_avail_and_initialized():
|
||||
return 0
|
||||
assert (
|
||||
LOCAL_PROCESS_GROUP is not None
|
||||
), "Local process group is not created! Please use launch() to spawn processes!"
|
||||
assert LOCAL_PROCESS_GROUP is not None, (
|
||||
"Local process group is not created! Please use launch() to spawn processes!"
|
||||
)
|
||||
return dist.get_rank(group=LOCAL_PROCESS_GROUP)
|
||||
|
||||
|
||||
|
||||
@@ -71,9 +71,9 @@ class TensorDataclass:
|
||||
set _shape to be the broadcasted shape.
|
||||
"""
|
||||
for k, v in self._field_custom_dimensions.items():
|
||||
assert (
|
||||
isinstance(v, int) and v > 1
|
||||
), f"Custom dimensions must be an integer greater than 1, since 1 is the default, received {k}: {v}"
|
||||
assert isinstance(v, int) and v > 1, (
|
||||
f"Custom dimensions must be an integer greater than 1, since 1 is the default, received {k}: {v}"
|
||||
)
|
||||
|
||||
# Shim to prevent pyright from narrowing `self` to DataclassInstance.
|
||||
self_dc = self
|
||||
|
||||
@@ -503,7 +503,7 @@ class LocalWriter:
|
||||
"""
|
||||
step = GLOBAL_BUFFER["step"]
|
||||
fraction_done = step / GLOBAL_BUFFER["max_iter"]
|
||||
curr_mssg = f"{step} ({fraction_done*100:.02f}%)"
|
||||
curr_mssg = f"{step} ({fraction_done * 100:.02f}%)"
|
||||
curr_mssg = f"{curr_mssg:<20}"
|
||||
for name, v in latest_map.items():
|
||||
if name in self.stats_to_track:
|
||||
|
||||
@@ -211,9 +211,9 @@ class ViewerControl:
|
||||
origin = scene_pointer_msg.ray_origin
|
||||
direction = scene_pointer_msg.ray_direction
|
||||
screen_pos = scene_pointer_msg.screen_pos[0]
|
||||
assert (origin is not None) and (
|
||||
direction is not None
|
||||
), "Origin and direction should not be None for click event."
|
||||
assert (origin is not None) and (direction is not None), (
|
||||
"Origin and direction should not be None for click event."
|
||||
)
|
||||
origin = tuple([x / VISER_NERFSTUDIO_SCALE_RATIO for x in origin])
|
||||
assert len(origin) == 3
|
||||
pointer_event = ViewerClick(origin, direction, screen_pos)
|
||||
|
||||
@@ -394,7 +394,7 @@ class ViewerLegacyState:
|
||||
bgr[:, :t, :] = bc
|
||||
|
||||
camera_json = eval_dataset.cameras.to_json(camera_idx=idx, image=bgr, max_size=100)
|
||||
self.viser_server.add_dataset_image(idx=f"{idx+len(train_dataset):06d}", json=camera_json)
|
||||
self.viser_server.add_dataset_image(idx=f"{idx + len(train_dataset):06d}", json=camera_json)
|
||||
|
||||
# draw the scene box (i.e., the bounding box)
|
||||
self.viser_server.update_scene_box(train_dataset.scene_box)
|
||||
|
||||
Reference in new issue
Block a user