rerun formatting with ruff 0.9.1 (#3569)

rerun with ruff 0.9.1
This commit is contained in:
Justin Kerr authored and GitHub committed 2025-01-13 10:46:11 -08:00
1 parent 5be513e968
commit 66cd6817f9
29 files changed
+92 -92

No files matched your search

@@ -541,7 +541,7 @@
"encoded_values = torch.moveaxis(encoded_values, 2, 0)\n", "encoded_values = torch.moveaxis(encoded_values, 2, 0)\n",
"\n", "\n",
"for level in range(levels):\n", "for level in range(levels):\n",
" print(f\"Level: {level+1}\")\n", " print(f\"Level: {level + 1}\")\n",
" media.show_images(encoded_values[level**2 : (level + 1) ** 2, ...], cmap=\"plasma\", border=True)" " media.show_images(encoded_values[level**2 : (level + 1) ** 2, ...], cmap=\"plasma\", border=True)"
] ]
} }
+9 -9
View File
@@ -205,9 +205,9 @@ class Cameras(TensorDataclass):
elif isinstance(camera_type, int): elif isinstance(camera_type, int):
camera_type = torch.tensor([camera_type], device=self.device) camera_type = torch.tensor([camera_type], device=self.device)
elif isinstance(camera_type, torch.Tensor): elif isinstance(camera_type, torch.Tensor):
assert not torch.is_floating_point( assert not torch.is_floating_point(camera_type), (
camera_type f"camera_type tensor must be of type int, not: {camera_type.dtype}"
), f"camera_type tensor must be of type int, not: {camera_type.dtype}" )
camera_type = camera_type.to(self.device) camera_type = camera_type.to(self.device)
if camera_type.ndim == 0 or camera_type.shape[-1] != 1: if camera_type.ndim == 0 or camera_type.shape[-1] != 1:
camera_type = camera_type.unsqueeze(-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 the camera indices are an int, then we need to make sure that the camera batch is 1D
if isinstance(camera_indices, int): if isinstance(camera_indices, int):
assert ( assert len(cameras.shape) == 1, (
len(cameras.shape) == 1 "camera_indices must be a tensor if cameras are batched with more than 1 batch dimension"
), "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) camera_indices = torch.tensor([camera_indices], device=cameras.device)
assert camera_indices.shape[-1] == len( assert camera_indices.shape[-1] == len(cameras.shape), (
cameras.shape "camera_indices must have shape (num_rays:..., num_cameras_batch_dims)"
), "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 # 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 # 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) data = dataset.get_data(idx, image_type=self.config.cache_images_type)
camera = dataset.cameras[idx].reshape(()) camera = dataset.cameras[idx].reshape(())
assert data["image"].shape[1] == camera.width.item() and data["image"].shape[0] == camera.height.item(), ( 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"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"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): if camera.distortion_params is None or torch.all(camera.distortion_params == 0):
return data return data
@@ -47,7 +47,7 @@ def downscale(img, scale: int) -> np.ndarray:
return img return img
height, width = img.shape[:2] height, width = img.shape[:2]
if height % scale > 0 or width % scale > 0: 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 out_height, out_width = height // scale, width // scale
resized = cv2.resize(img, (out_width, out_height), cv2.INTER_AREA) # type: ignore resized = cv2.resize(img, (out_width, out_height), cv2.INTER_AREA) # type: ignore
return resized return resized
@@ -476,7 +476,7 @@ class Nerfstudio(DataParser):
while True: while True:
if (max_res / 2 ** (df)) <= MAX_AUTO_RESOLUTION: if (max_res / 2 ** (df)) <= MAX_AUTO_RESOLUTION:
break 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 break
df += 1 df += 1
@@ -91,9 +91,9 @@ class NuScenes(DataParser):
) )
cameras = ["CAM_" + camera for camera in self.config.cameras] cameras = ["CAM_" + camera for camera in self.config.cameras]
assert ( assert len(cameras) == 1, (
len(cameras) == 1 "waiting on multiple camera support"
), "waiting on multiple camera support" # TODO: remove once multiple cameras are supported ) # TODO: remove once multiple cameras are supported
# get samples for scene # get samples for scene
samples = [ samples = [
+3 -3
View File
@@ -128,9 +128,9 @@ class InputDataset(Dataset):
if self._dataparser_outputs.mask_filenames is not None: if self._dataparser_outputs.mask_filenames is not None:
mask_filepath = self._dataparser_outputs.mask_filenames[image_idx] 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) data["mask"] = get_image_mask_tensor_from_path(filepath=mask_filepath, scale_factor=self.scale_factor)
assert ( assert data["mask"].shape[:2] == data["image"].shape[:2], (
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]}"
), f"Mask and image have different shapes. Got {data['mask'].shape[:2]} and {data['image'].shape[:2]}" )
if self.mask_color: if self.mask_color:
data["image"] = torch.where( data["image"] = torch.where(
data["mask"] == 1.0, data["image"], torch.ones_like(data["image"]) * torch.tensor(self.mask_color) data["mask"] == 1.0, data["image"], torch.ones_like(data["image"]) * torch.tensor(self.mask_color)
+3 -3
View File
@@ -556,9 +556,9 @@ class PairPixelSampler(PixelSampler): # pylint: disable=too-few-public-methods
) -> Int[Tensor, "batch_size 3"]: ) -> Int[Tensor, "batch_size 3"]:
rays_to_sample = self.rays_to_sample rays_to_sample = self.rays_to_sample
if batch_size is not None: if batch_size is not None:
assert ( assert int(batch_size) % 2 == 0, (
int(batch_size) % 2 == 0 f"PairPixelSampler can only return batch sizes in multiples of two (got {batch_size})"
), f"PairPixelSampler can only return batch sizes in multiples of two (got {batch_size})" )
rays_to_sample = batch_size // 2 rays_to_sample = batch_size // 2
if isinstance(mask, Tensor) and not self.config.ignore_mask: if isinstance(mask, Tensor) and not self.config.ignore_mask:
+7 -5
View File
@@ -27,7 +27,7 @@ import torch.utils.data
from nerfstudio.cameras.cameras import Cameras from nerfstudio.cameras.cameras import Cameras
NERFSTUDIO_COLLATE_ERR_MSG_FORMAT = ( 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]") 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((isinstance(cam, Cameras) for cam in batch))
assert all((cam.distortion_params is None for cam in batch)) or all( assert all((cam.distortion_params is None for cam in batch)) or all(
(cam.distortion_params is not None for cam in batch) (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." Generalized batching will be supported in the future."
)
if batch[0].metadata is not None: if batch[0].metadata is not None:
metadata_keys = batch[0].metadata.keys() metadata_keys = batch[0].metadata.keys()
assert all( assert all((cam.metadata.keys() == metadata_keys for cam in batch)), (
(cam.metadata.keys() == metadata_keys for cam in batch) "All cameras must have the same metadata keys."
), "All cameras must have the same metadata keys." )
else: else:
assert all((cam.metadata is None for cam in batch)), "All cameras must have the same metadata keys." assert all((cam.metadata is None for cam in batch)), "All cameras must have the same metadata keys."
+3 -3
View File
@@ -80,9 +80,9 @@ class TrainingCallback:
args: Optional[List] = None, args: Optional[List] = None,
kwargs: Optional[Dict] = None, kwargs: Optional[Dict] = None,
): ):
assert ( assert "step" in signature(func).parameters.keys(), (
"step" in signature(func).parameters.keys() f"'step: int' must be an argument in the callback function 'func': {func.__name__}"
), f"'step: int' must be an argument in the callback function 'func': {func.__name__}" )
self.where_to_run = where_to_run self.where_to_run = where_to_run
self.update_every_num_iters = update_every_num_iters self.update_every_num_iters = update_every_num_iters
self.iters = iters self.iters = iters
+3 -3
View File
@@ -148,9 +148,9 @@ def generate_point_cloud(
CONSOLE.print(f"Please set --normal_output_name to one of: {outputs.keys()}", justify="center") CONSOLE.print(f"Please set --normal_output_name to one of: {outputs.keys()}", justify="center")
sys.exit(1) sys.exit(1)
normal = outputs[normal_output_name] normal = outputs[normal_output_name]
assert ( assert torch.min(normal) >= 0.0 and torch.max(normal) <= 1.0, (
torch.min(normal) >= 0.0 and torch.max(normal) <= 1.0 "Normal values from method output must be in [0, 1]"
), "Normal values from method output must be in [0, 1]" )
normal = (normal * 2.0) - 1.0 normal = (normal * 2.0) - 1.0
point = ray_bundle.origins + ray_bundle.directions * depth point = ray_bundle.origins + ray_bundle.directions * depth
view_direction = ray_bundle.directions view_direction = ray_bundle.directions
+3 -3
View File
@@ -369,9 +369,9 @@ class HashEncoding(Encoding):
) )
if self.tcnn_encoding is None: if self.tcnn_encoding is None:
assert ( assert interpolation is None or interpolation == "Linear", (
interpolation is None or interpolation == "Linear" f"interpolation '{interpolation}' is not supported for torch encoding backend"
), f"interpolation '{interpolation}' is not supported for torch encoding backend" )
def build_nn_modules(self) -> None: def build_nn_modules(self) -> None:
"""Initialize the torch version of the hash encoding.""" """Initialize the torch version of the hash encoding."""
+3 -3
View File
@@ -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._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._density_before_activation is not None, "Density must be set before calling get_normals."
assert ( assert self._sample_locations.shape[:-1] == self._density_before_activation.shape[:-1], (
self._sample_locations.shape[:-1] == self._density_before_activation.shape[:-1] "Sample locations and density must have the same shape besides the last dimension."
), "Sample locations and density must have the same shape besides the last dimension." )
normals = torch.autograd.grad( normals = torch.autograd.grad(
self._density_before_activation, self._density_before_activation,
+3 -3
View File
@@ -330,9 +330,9 @@ class PDFSampler(Sampler):
u = u.expand(size=(*cdf.shape[:-1], num_bins)) u = u.expand(size=(*cdf.shape[:-1], num_bins))
u = u.contiguous() u = u.contiguous()
assert ( assert ray_samples.spacing_starts is not None and ray_samples.spacing_ends is not None, (
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"
), "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" assert ray_samples.spacing_to_euclidean_fn is not None, "ray_samples.spacing_to_euclidean_fn must be provided"
existing_bins = torch.cat( existing_bins = torch.cat(
[ [
+3 -3
View File
@@ -193,9 +193,9 @@ class SurfaceModel(Model):
Returns: Returns:
Outputs of model. (ie. rendered colors) Outputs of model. (ie. rendered colors)
""" """
assert ( assert ray_bundle.metadata is not None and "directions_norm" in ray_bundle.metadata, (
ray_bundle.metadata is not None and "directions_norm" in ray_bundle.metadata "directions_norm is required 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) samples_and_field_outputs = self.sample_and_forward_field(ray_bundle=ray_bundle)
+3 -3
View File
@@ -327,9 +327,9 @@ class TensoRFModel(Model):
elif self.config.regularization == "tv": elif self.config.regularization == "tv":
density_plane_coef = self.field.density_encoding.plane_coef density_plane_coef = self.field.density_encoding.plane_coef
color_plane_coef = self.field.color_encoding.plane_coef color_plane_coef = self.field.color_encoding.plane_coef
assert isinstance(color_plane_coef, torch.Tensor) and isinstance( assert isinstance(color_plane_coef, torch.Tensor) and isinstance(density_plane_coef, torch.Tensor), (
density_plane_coef, torch.Tensor "TV reg only supported for TensoRF encoding types with plane_coef attribute"
), "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_density"] = tv_loss(density_plane_coef)
loss_dict["tv_reg_color"] = tv_loss(color_plane_coef) loss_dict["tv_reg_color"] = tv_loss(color_plane_coef)
elif self.config.regularization == "none": elif self.config.regularization == "none":
+3 -3
View File
@@ -422,9 +422,9 @@ class VanillaPipeline(Pipeline):
self, step: Optional[int] = None, output_path: Optional[Path] = None, get_std: bool = False self, step: Optional[int] = None, output_path: Optional[Path] = None, get_std: bool = False
): ):
"""Get the average metrics for evaluation images.""" """Get the average metrics for evaluation images."""
assert hasattr( assert hasattr(self.datamanager, "fixed_indices_eval_dataloader"), (
self.datamanager, "fixed_indices_eval_dataloader" "datamanager must have 'fixed_indices_eval_dataloader' attribute"
), "datamanager must have 'fixed_indices_eval_dataloader' attribute" )
image_prefix = "eval" image_prefix = "eval"
return self.get_average_image_metrics( return self.get_average_image_metrics(
self.datamanager.fixed_indices_eval_dataloader, image_prefix, step, output_path, get_std self.datamanager.fixed_indices_eval_dataloader, image_prefix, step, output_path, get_std
+3 -3
View File
@@ -54,9 +54,9 @@ class DynamicBatchPipeline(VanillaPipeline):
grad_scaler: Optional[GradScaler] = None, grad_scaler: Optional[GradScaler] = None,
): ):
super().__init__(config, device, test_mode, world_size, local_rank) super().__init__(config, device, test_mode, world_size, local_rank)
assert isinstance( assert isinstance(self.datamanager, VanillaDataManager), (
self.datamanager, VanillaDataManager "DynamicBatchPipeline only works with 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.dynamic_num_rays_per_batch = self.config.target_num_samples // self.config.max_num_samples_per_ray
self._update_pixel_samplers() self._update_pixel_samplers()
@@ -145,9 +145,7 @@ class ColmapConverterToNerfstudioDataset(BaseConverterToNerfstudioDataset):
summary_log.append(colmap_utils.get_matching_summary(num_frames, num_matched_frames)) summary_log.append(colmap_utils.get_matching_summary(num_frames, num_matched_frames))
else: else:
CONSOLE.log( CONSOLE.log("[bold yellow]Warning: Could not find existing COLMAP results. Not generating transforms.json")
"[bold yellow]Warning: Could not find existing COLMAP results. " "Not generating transforms.json"
)
return summary_log return summary_log
def _export_depth(self) -> Tuple[Optional[Dict[int, Path]], List[str]]: def _export_depth(self) -> Tuple[Optional[Dict[int, Path]], List[str]]:
@@ -224,7 +222,7 @@ class ColmapConverterToNerfstudioDataset(BaseConverterToNerfstudioDataset):
) )
elif sfm_tool == "hloc": elif sfm_tool == "hloc":
if mask_path is not None: 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 feature_type is not None
assert matcher_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, use_single_camera_mode=self.use_single_camera_mode,
) )
else: 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: def __post_init__(self) -> None:
super().__post_init__() super().__post_init__()
+2 -2
View File
@@ -70,9 +70,9 @@ def polycam_to_json(
frame["cy"] = frame_json["cy"] - crop_border_pixels frame["cy"] = frame_json["cy"] - crop_border_pixels
frame["w"] = frame_json["width"] - crop_border_pixels * 2 frame["w"] = frame_json["width"] - crop_border_pixels * 2
frame["h"] = frame_json["height"] - 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: 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. # Transform matrix to nerfstudio format. Please refer to the documentation for coordinate system conventions.
frame["transform_matrix"] = [ frame["transform_matrix"] = [
[frame_json["t_20"], frame_json["t_21"], frame_json["t_22"], frame_json["t_23"]], [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 = "" crop_cmd = ""
if crop_border_pixels is not None: 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): elif crop_factor != (0.0, 0.0, 0.0, 0.0):
height = 1 - crop_factor[0] - crop_factor[1] height = 1 - crop_factor[0] - crop_factor[1]
width = 1 - crop_factor[2] - crop_factor[3] width = 1 - crop_factor[2] - crop_factor[3]
@@ -484,7 +484,7 @@ def downscale_images(
run_command(ffmpeg_cmd, verbose=verbose) run_command(ffmpeg_cmd, verbose=verbose)
CONSOLE.log("[bold green]:tada: Done downscaling images.") 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] downscale_text = ", ".join(downscale_text[:-1]) + " and " + downscale_text[-1]
return f"We downsampled the images by {downscale_text}" return f"We downsampled the images by {downscale_text}"
+12 -12
View File
@@ -289,9 +289,9 @@ class PhototourismDownload(DatasetDownload):
PhototourismDownload(capture_name=capture_name).download(save_dir) PhototourismDownload(capture_name=capture_name).download(save_dir)
return return
assert ( assert self.capture_name in phototourism_downloads, (
self.capture_name in phototourism_downloads f"Capture name {self.capture_name} not found in {phototourism_downloads.keys()}"
), f"Capture name {self.capture_name} not found in {phototourism_downloads.keys()}" )
url = phototourism_downloads[self.capture_name] url = phototourism_downloads[self.capture_name]
target_path = str(save_dir / "phototourism" / self.capture_name) target_path = str(save_dir / "phototourism" / self.capture_name)
os.makedirs(target_path, exist_ok=True) os.makedirs(target_path, exist_ok=True)
@@ -350,9 +350,9 @@ class SDFstudioDemoDownload(DatasetDownload):
SDFstudioDemoDownload(dataset_name=dataset_name).download(save_dir) SDFstudioDemoDownload(dataset_name=dataset_name).download(save_dir)
return return
assert ( assert self.dataset_name in sdfstudio_downloads, (
self.dataset_name in sdfstudio_downloads f"Capture name {self.dataset_name} not found in {sdfstudio_downloads.keys()}"
), f"Capture name {self.dataset_name} not found in {sdfstudio_downloads.keys()}" )
url = sdfstudio_downloads[self.dataset_name] url = sdfstudio_downloads[self.dataset_name]
@@ -421,9 +421,9 @@ class NeRFOSRDownload(DatasetDownload):
NeRFOSRDownload(capture_name=capture_name).download(save_dir) NeRFOSRDownload(capture_name=capture_name).download(save_dir)
return return
assert ( assert self.capture_name in nerfosr_downloads, (
self.capture_name in nerfosr_downloads f"Capture name {self.capture_name} not found in {nerfosr_downloads.keys()}"
), f"Capture name {self.capture_name} not found in {nerfosr_downloads.keys()}" )
url = nerfosr_downloads[self.capture_name] url = nerfosr_downloads[self.capture_name]
target_path = str(save_dir / "nerfosr" / self.capture_name) target_path = str(save_dir / "nerfosr" / self.capture_name)
os.makedirs(target_path, exist_ok=True) os.makedirs(target_path, exist_ok=True)
@@ -475,9 +475,9 @@ class Mill19Download(DatasetDownload):
Mill19Download(capture_name=capture_name).download(save_dir) Mill19Download(capture_name=capture_name).download(save_dir)
return return
assert ( assert self.capture_name in mill19_downloads, (
self.capture_name in mill19_downloads f"Capture name {self.capture_name} not found in {mill19_downloads.keys()}"
), f"Capture name {self.capture_name} not found in {mill19_downloads.keys()}" )
url = mill19_downloads[self.capture_name] url = mill19_downloads[self.capture_name]
target_path = save_dir / "mill19" / self.capture_name target_path = save_dir / "mill19" / self.capture_name
target_path.mkdir(parents=True, exist_ok=True) target_path.mkdir(parents=True, exist_ok=True)
+1 -1
View File
@@ -360,7 +360,7 @@ class EyefulTowerDownload(DatasetDownload):
+ includes + includes
+ [base_url, str(output_path)] + [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( print(
f"\tDownloading resolutions {resolutions}", f"\tDownloading resolutions {resolutions}",
f"to '{output_path.resolve()}' with command `aws {' '.join(command)}` ...", f"to '{output_path.resolve()}' with command `aws {' '.join(command)}` ...",
+4 -4
View File
@@ -556,9 +556,9 @@ class RenderCameraPath(BaseRender):
self.output_path = Path(str(left_eye_path.parent)[:-5]) self.output_path = Path(str(left_eye_path.parent)[:-5])
self.output_path.mkdir(parents=True, exist_ok=True) self.output_path.mkdir(parents=True, exist_ok=True)
if self.image_format == "png": 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": 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) run_command(ffmpeg_ods_command, verbose=False)
# remove the temp files directory # 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 = Path(str(left_eye_path.parent)[:-5])
self.output_path.mkdir(parents=True, exist_ok=True) self.output_path.mkdir(parents=True, exist_ok=True)
if self.image_format == "png": 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": 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) run_command(ffmpeg_vr180_command, verbose=False)
# remove the temp files directory # remove the temp files directory
+3 -3
View File
@@ -42,9 +42,9 @@ def get_local_rank() -> int:
"""The rank of the current process within the local (per-machine) process group.""" """The rank of the current process within the local (per-machine) process group."""
if not is_dist_avail_and_initialized(): if not is_dist_avail_and_initialized():
return 0 return 0
assert ( assert LOCAL_PROCESS_GROUP is not None, (
LOCAL_PROCESS_GROUP is not None "Local process group is not created! Please use launch() to spawn processes!"
), "Local process group is not created! Please use launch() to spawn processes!" )
return dist.get_rank(group=LOCAL_PROCESS_GROUP) return dist.get_rank(group=LOCAL_PROCESS_GROUP)
+3 -3
View File
@@ -71,9 +71,9 @@ class TensorDataclass:
set _shape to be the broadcasted shape. set _shape to be the broadcasted shape.
""" """
for k, v in self._field_custom_dimensions.items(): for k, v in self._field_custom_dimensions.items():
assert ( assert isinstance(v, int) and v > 1, (
isinstance(v, int) and v > 1 f"Custom dimensions must be an integer greater than 1, since 1 is the default, received {k}: {v}"
), 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. # Shim to prevent pyright from narrowing `self` to DataclassInstance.
self_dc = self self_dc = self
+1 -1
View File
@@ -503,7 +503,7 @@ class LocalWriter:
""" """
step = GLOBAL_BUFFER["step"] step = GLOBAL_BUFFER["step"]
fraction_done = step / GLOBAL_BUFFER["max_iter"] 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}" curr_mssg = f"{curr_mssg:<20}"
for name, v in latest_map.items(): for name, v in latest_map.items():
if name in self.stats_to_track: if name in self.stats_to_track:
+3 -3
View File
@@ -211,9 +211,9 @@ class ViewerControl:
origin = scene_pointer_msg.ray_origin origin = scene_pointer_msg.ray_origin
direction = scene_pointer_msg.ray_direction direction = scene_pointer_msg.ray_direction
screen_pos = scene_pointer_msg.screen_pos[0] screen_pos = scene_pointer_msg.screen_pos[0]
assert (origin is not None) and ( assert (origin is not None) and (direction is not None), (
direction is not None "Origin and direction should not be None for click event."
), "Origin and direction should not be None for click event." )
origin = tuple([x / VISER_NERFSTUDIO_SCALE_RATIO for x in origin]) origin = tuple([x / VISER_NERFSTUDIO_SCALE_RATIO for x in origin])
assert len(origin) == 3 assert len(origin) == 3
pointer_event = ViewerClick(origin, direction, screen_pos) pointer_event = ViewerClick(origin, direction, screen_pos)
@@ -394,7 +394,7 @@ class ViewerLegacyState:
bgr[:, :t, :] = bc bgr[:, :t, :] = bc
camera_json = eval_dataset.cameras.to_json(camera_idx=idx, image=bgr, max_size=100) 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) # draw the scene box (i.e., the bounding box)
self.viser_server.update_scene_box(train_dataset.scene_box) self.viser_server.update_scene_box(train_dataset.scene_box)