SupervisedLoss

class packnet_sfm.losses.supervised_loss.BerHuLoss(threshold=0.2)[source]

Bases: torch.nn.modules.module.Module

Class implementing the BerHu loss.

forward(pred, gt)[source]

Calculates the BerHu loss.

Parameters
  • pred (torch.Tensor [B,1,H,W]) – Predicted inverse depth map

  • gt (torch.Tensor [B,1,H,W]) – Ground-truth inverse depth map

Returns

loss – BerHu loss

Return type

torch.Tensor [1]

class packnet_sfm.losses.supervised_loss.SilogLoss(ratio=10, ratio2=0.85)[source]

Bases: torch.nn.modules.module.Module

forward(pred, gt)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class packnet_sfm.losses.supervised_loss.SupervisedLoss(supervised_method='sparse-l1', supervised_num_scales=4, progressive_scaling=0.0, **kwargs)[source]

Bases: packnet_sfm.losses.loss_base.LossBase

Supervised loss for inverse depth maps.

Parameters
  • supervised_method (str) – Which supervised method will be used

  • supervised_num_scales (int) – Number of scales used by the supervised loss

  • progressive_scaling (float) – Training percentage for progressive scaling (0.0 to disable)

  • kwargs (dict) – Extra parameters

calculate_loss(inv_depths, gt_inv_depths)[source]

Calculate the supervised loss.

Parameters
  • inv_depths (list of torch.Tensor [B,1,H,W]) – List of predicted inverse depth maps

  • gt_inv_depths (list of torch.Tensor [B,1,H,W]) – List of ground-truth inverse depth maps

Returns

loss – Average supervised loss for all scales

Return type

torch.Tensor [1]

forward(inv_depths, gt_inv_depth, return_logs=False, progress=0.0)[source]

Calculates training supervised loss.

Parameters
  • inv_depths (list of torch.Tensor [B,1,H,W]) – Predicted depth maps for the original image, in all scales

  • gt_inv_depth (torch.Tensor [B,1,H,W]) – Ground-truth depth map for the original image

  • return_logs (bool) – True if logs are saved for visualization

  • progress (float) – Training percentage

Returns

losses_and_metrics – Output dictionary

Return type

dict

property logs

Returns class logs.

packnet_sfm.losses.supervised_loss.get_loss_func(supervised_method)[source]

Determines the supervised loss to be used, given the supervised method.