Skip to content

Commit

Permalink
Fixing resize_image and adding additional distortion check (#3162)
Browse files Browse the repository at this point in the history
adding fixes for the runtime error on masking as well as distortion checking

Co-authored-by: J.Y <[email protected]>
  • Loading branch information
AntonioMacaronio and jb-ye authored May 25, 2024
1 parent 5a341ea commit 456930c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nerfstudio/data/datamanagers/full_images_datamanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def undistort_idx(idx: int) -> Dict[str, torch.Tensor]:
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:
if camera.distortion_params is None or torch.all(camera.distortion_params == 0):
return data
K = camera.get_intrinsics_matrices().numpy()
distortion_params = camera.distortion_params.numpy()
Expand Down
1 change: 1 addition & 0 deletions nerfstudio/models/splatfacto.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def resize_image(image: torch.Tensor, d: int):
"""
import torch.nn.functional as tf

image = image.to(torch.float32)
weight = (1.0 / (d * d)) * torch.ones((1, 1, d, d), dtype=torch.float32, device=image.device)
return tf.conv2d(image.permute(2, 0, 1)[:, None, ...], weight, stride=d).squeeze(1).permute(1, 2, 0)

Expand Down

0 comments on commit 456930c

Please sign in to comment.