π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
better signature name, update docs definition
edgarriba00a827b227a6
diff --git a/docs/source/losses.rst b/docs/source/losses.rstindex ba3532f1a..cdba74861 100644--- a/docs/source/losses.rst+++ b/docs/source/losses.rst@@ -8,10 +8,10 @@ torchgeometry.losses.. autofunction:: tversky_loss.. autofunction:: focal_loss.. autofunction:: ssim-.. autofunction:: depth_smoothness_loss+.. autofunction:: inverse_depth_smoothness_loss.. autoclass:: DiceLoss.. autoclass:: TverskyLoss.. autoclass:: FocalLoss.. autoclass:: SSIM-.. autoclass:: DepthSmoothnessLoss+.. autoclass:: InverseDepthSmoothnessLossdiff --git a/test/test_losses.py b/test/test_losses.pyindex e83d9259c..cfbfe46f1 100644--- a/test/test_losses.py+++ b/test/test_losses.py@@ -181,7 +181,7 @@ class TestDepthSmoothnessLoss:image = self.image.clone()depth = self.depth.clone()- criterion = tgm.losses.InvDepthSmoothnessLoss()+ criterion = tgm.losses.InverseDepthSmoothnessLoss()loss = criterion(depth, image)# TODO: implement me@@ -197,7 +197,7 @@ class TestDepthSmoothnessLoss:depth = self.depth.clone()depth = utils.tensor_to_gradcheck_var(depth) # to varimage = utils.tensor_to_gradcheck_var(image) # to var- assert gradcheck(tgm.losses.inv_depth_smoothness_loss,+ assert gradcheck(tgm.losses.inverse_depth_smoothness_loss,(depth, image,), raise_exception=True)@pytest.mark.parametrize("batch_shape",diff --git a/torchgeometry/losses/__init__.py b/torchgeometry/losses/__init__.pyindex c1c410c93..c243ff6a6 100644--- a/torchgeometry/losses/__init__.py+++ b/torchgeometry/losses/__init__.py@@ -3,4 +3,4 @@ from .ssim import SSIM, ssimfrom .dice import DiceLoss, dice_lossfrom .tversky import TverskyLoss, tversky_lossfrom .focal import FocalLoss, focal_loss-from .depth_smooth import InvDepthSmoothnessLoss, inv_depth_smoothness_loss+from .depth_smooth import InverseDepthSmoothnessLoss, inverse_depth_smoothness_lossdiff --git a/torchgeometry/losses/depth_smooth.py b/torchgeometry/losses/depth_smooth.pyindex 8378cf746..ab1d3bee3 100644--- a/torchgeometry/losses/depth_smooth.py+++ b/torchgeometry/losses/depth_smooth.py@@ -6,7 +6,7 @@ import torch.nn.functional as F# https://github.com/tensorflow/models/blob/master/research/struct2depth/model.py#L625-L641-class InvDepthSmoothnessLoss(nn.Module):+class InverseDepthSmoothnessLoss(nn.Module):r"""Criterion that computes image-aware inverse depth smoothness loss... math::@@ -30,7 +30,7 @@ class InvDepthSmoothnessLoss(nn.Module):"""def __init__(self) -> None:- super(InvDepthSmoothnessLoss, self).__init__()+ super(InverseDepthSmoothnessLoss, self).__init__()@staticmethoddef gradient_x(img: torch.Tensor) -> torch.Tensor:@@ -42,10 +42,7 @@ class InvDepthSmoothnessLoss(nn.Module):assert len(img.shape) == 4, img.shapereturn img[:, :, :-1, :] - img[:, :, 1:, :]- def forward(- self,- idepth: torch.Tensor,- image: torch.Tensor) -> torch.Tensor:+ def forward(self, idepth: torch.Tensor, image: torch.Tensor) -> torch.Tensor:if not torch.is_tensor(idepth):raise TypeError("Input idepth type is not a torch.Tensor. Got {}".format(type(idepth)))@@ -92,11 +89,11 @@ class InvDepthSmoothnessLoss(nn.Module):######################-def inv_depth_smoothness_loss(+def inverse_depth_smoothness_loss(idepth: torch.Tensor,image: torch.Tensor) -> torch.Tensor:r"""Computes image-aware inverse depth smoothness loss.See :class:`~torchgeometry.losses.InvDepthSmoothnessLoss` for details."""- return InvDepthSmoothnessLoss()(idepth, image)+ return InverseDepthSmoothnessLoss()(idepth, image)