Loss functions commonly used in computer vision tasks. For general losses (Cross-Entropy, MSE, KL Divergence), see General losses. For CV evaluation metrics, see Computer vision metrics.

Focal Loss

Focal loss addresses class imbalance by down-weighting the contribution of easy examples.

Where:

  • is the probability of the correct class
  • is a balancing factor
  • is a focusing parameter

Applications:

  • Object detection (RetinaNet)
  • Segmentation with imbalanced classes
  • Medical image analysis

Dice Loss

Dice loss is based on the Dice coefficient, which measures the overlap between predicted and ground truth segmentation.

Where:

  • is the predicted probability
  • is the ground truth binary mask

Applications:

  • Medical image segmentation
  • Semantic segmentation
  • Instance segmentation

Variants:

  • Tversky Loss: Generalization of Dice loss that allows for tuning precision and recall.
  • Combo Loss: Combination of Dice loss and weighted cross-entropy.

IoU (Intersection over Union)/Jaccard Loss

IoU loss is based on the IoU metric and helps directly optimize the quality of bounding box predictions.

Applications:

  • Object detection
  • Instance segmentation
  • Bounding box regression

Perceptual Loss

Perceptual loss compares high-level feature representations extracted by a pre-trained CNN instead of pixel-wise differences.

Where:

  • is the feature map from the -th layer of a pre-trained network
  • is the ground truth image
  • is the generated image
  • are the dimensions of the feature map

Applications:

  • Super-resolution
  • Style transfer
  • Image-to-image translation
  • Image generation

Adversarial Loss

Adversarial loss comes from Generative Adversarial Networks (GANs) and involves a minimax game between a generator and discriminator.

Where:

  • is the discriminator
  • is the generator
  • is the real data distribution
  • is the noise distribution

Applications:

  • Image generation
  • Image-to-image translation
  • Domain adaptation
  • Text-to-image generation

Variants:

  • WGAN Loss: Uses Wasserstein distance to provide more stable gradients.
  • LSGAN Loss: Uses least squares instead of log-likelihood for more stable training.
  • Hinge Loss: Alternative formulation that has shown good results for image generation.

SSIM (Structural Similarity Index) Loss

SSIM loss measures the structural similarity between images, focusing on structural information, luminance, and contrast.

Where:

  • , are the average pixel values
  • , are the variances
  • is the covariance
  • , are constants to avoid division by zero

Applications:

  • Image restoration
  • Super-resolution
  • Image compression
  • Image quality assessment