kaira.losses.image.VGGLoss

Inheritance diagram of VGGLoss

Inheritance diagram for VGGLoss

class kaira.losses.image.VGGLoss(layer_weights=None)[source]

Bases: BaseLoss

VGG Perceptual Loss Module.

This module calculates the perceptual loss using features extracted by the VGG network. VGG loss measures similarity in feature space rather than pixel space, capturing perceptual differences better [Johnson et al., 2016] [Dosovitskiy and Brox, 2016].

Methods

__init__

Initialize the VGGLoss module.

forward

Forward pass through the VGGLoss module.

__init__(layer_weights=None)[source]

Initialize the VGGLoss module.

Parameters:

layer_weights (dict, optional) – Weights for different VGG layers. Default is {‘conv1_2’: 0.1, ‘conv2_2’: 0.2, ‘conv3_3’: 0.4, ‘conv4_3’: 0.3}

forward(x: Tensor, target: Tensor) Tensor[source]

Forward pass through the VGGLoss module.

Parameters:
Returns:

The VGG perceptual loss between the input and the target.

Return type:

torch.Tensor