Skip to content

Commit ca24c2c

Browse files
Clamp values to prevent overshooting
1 parent 73fe54d commit ca24c2c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

nerfstudio/process_data/equirect_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ def remap_cubic(
8080

8181
grid = torch.stack((grid_x, grid_y), dim=-1).unsqueeze(0).expand(batch_size, -1, -1, -1)
8282

83-
return torch.nn.functional.grid_sample(img, grid, mode="bicubic", padding_mode="zeros")
83+
result = torch.nn.functional.grid_sample(img, grid, mode="bicubic", padding_mode="zeros")
84+
85+
# Clamp the output to the valid range [0, 1] to prevent artifacts due to overshooting
86+
return torch.clamp(result, 0.0, 1.0)
8487

8588

8689
def equirect2persp(img: torch.Tensor, fov: int, theta: int, phi: int, hd: int, wd: int) -> torch.Tensor:

0 commit comments

Comments
 (0)