mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-04 23:08:44 +08:00
Merge branch 'main' into ethan/visiblity-depth-nerfacto
This commit is contained in:
3 files changed
+8
-2
No files matched your search
@@ -387,6 +387,8 @@ def _undistort_image(
|
|||||||
mask = cv2.undistort(mask, K, distortion_params, None, newK) # type: ignore
|
mask = cv2.undistort(mask, K, distortion_params, None, newK) # type: ignore
|
||||||
mask = mask[y : y + h, x : x + w]
|
mask = mask[y : y + h, x : x + w]
|
||||||
mask = torch.from_numpy(mask).bool()
|
mask = torch.from_numpy(mask).bool()
|
||||||
|
if len(mask.shape) == 2:
|
||||||
|
mask = mask[:, :, None]
|
||||||
K = newK
|
K = newK
|
||||||
|
|
||||||
elif camera.camera_type.item() == CameraType.FISHEYE.value:
|
elif camera.camera_type.item() == CameraType.FISHEYE.value:
|
||||||
@@ -406,6 +408,8 @@ def _undistort_image(
|
|||||||
mask = mask.astype(np.uint8) * 255
|
mask = mask.astype(np.uint8) * 255
|
||||||
mask = cv2.fisheye.undistortImage(mask, K, distortion_params, None, newK)
|
mask = cv2.fisheye.undistortImage(mask, K, distortion_params, None, newK)
|
||||||
mask = torch.from_numpy(mask).bool()
|
mask = torch.from_numpy(mask).bool()
|
||||||
|
if len(mask.shape) == 2:
|
||||||
|
mask = mask[:, :, None]
|
||||||
K = newK
|
K = newK
|
||||||
elif camera.camera_type.item() == CameraType.FISHEYE624.value:
|
elif camera.camera_type.item() == CameraType.FISHEYE624.value:
|
||||||
fisheye624_params = torch.cat(
|
fisheye624_params = torch.cat(
|
||||||
@@ -498,6 +502,8 @@ def _undistort_image(
|
|||||||
)
|
)
|
||||||
/ 255.0
|
/ 255.0
|
||||||
).bool()[..., None]
|
).bool()[..., None]
|
||||||
|
if len(mask.shape) == 2:
|
||||||
|
mask = mask[:, :, None]
|
||||||
assert mask.shape == (undist_h, undist_w, 1)
|
assert mask.shape == (undist_h, undist_w, 1)
|
||||||
K = undist_K.numpy()
|
K = undist_K.numpy()
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ class NGPModel(Model):
|
|||||||
return metrics_dict
|
return metrics_dict
|
||||||
|
|
||||||
def get_loss_dict(self, outputs, batch, metrics_dict=None):
|
def get_loss_dict(self, outputs, batch, metrics_dict=None):
|
||||||
image = batch["image"][..., :3].to(self.device)
|
image = batch["image"].to(self.device)
|
||||||
pred_rgb, image = self.renderer_rgb.blend_background_for_loss_computation(
|
pred_rgb, image = self.renderer_rgb.blend_background_for_loss_computation(
|
||||||
pred_image=outputs["rgb"],
|
pred_image=outputs["rgb"],
|
||||||
pred_accumulation=outputs["accumulation"],
|
pred_accumulation=outputs["accumulation"],
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ class TensoRFModel(Model):
|
|||||||
def get_loss_dict(self, outputs, batch, metrics_dict=None) -> Dict[str, torch.Tensor]:
|
def get_loss_dict(self, outputs, batch, metrics_dict=None) -> Dict[str, torch.Tensor]:
|
||||||
# Scaling metrics by coefficients to create the losses.
|
# Scaling metrics by coefficients to create the losses.
|
||||||
device = outputs["rgb"].device
|
device = outputs["rgb"].device
|
||||||
image = batch["image"][..., :3].to(device)
|
image = batch["image"].to(device)
|
||||||
pred_image, image = self.renderer_rgb.blend_background_for_loss_computation(
|
pred_image, image = self.renderer_rgb.blend_background_for_loss_computation(
|
||||||
pred_image=outputs["rgb"],
|
pred_image=outputs["rgb"],
|
||||||
pred_accumulation=outputs["accumulation"],
|
pred_accumulation=outputs["accumulation"],
|
||||||
|
|||||||
Reference in new issue
Block a user