Layers

AffineImageTransformation

class AffineImageTransformation(img_size: tuple)[source]

Bases: sphinx.ext.autodoc.importer._MockObject

Layer to transform an input image by a given affine transformation matrix

Parameters:img_size (tuple) – the output image size
forward(input_image, affine_params)[source]

Performs the actual transformation

Parameters:
  • input_image (torch.Tensor) – the image which should be transformed
  • affine_params (torch.Tensor) – the affine transformation matrix (of shape Nx6)
Returns:

the transformed image

Return type:

torch.Tensor

AffineLandmarkTransformation

class AffineLandmarkTransformation[source]

Bases: sphinx.ext.autodoc.importer._MockObject

Layer to apply a given transformation matrix to a set of landmarks

forward(lmk_tensor, affine_tensor, inverse=False)[source]

the actual transformation

Parameters:
  • lmk_tensor (torch.Tensor) – the landmarks to transform (of shape N x Num_landmarks x 2)
  • affine_tensor (torch.Tensor) – the transformation to apply (of shape N x 6)
  • inverse (bool, optional) – whether to apply the given transformation or it’s inverse (the default is False)
Returns:

the transformed landmarks

Return type:

torch.Tensor

EstimateAffineParams

class EstimateAffineParams(mean_shape)[source]

Bases: sphinx.ext.autodoc.importer._MockObject

Layer to estimate the parameters of an affine transformation matrix, which would transform the mean_shape into a given shape

Parameters:mean_shape (torch.Tensor) – The mean shape
forward(transformed_shape)[source]

actual parameter estimation

Parameters:transformed_shape (torch.Tensor) – the target shape
Returns:the estimated transformation matrix
Return type:torch.Tensor

HeatMap

class HeatMap(img_size, patch_size)[source]

Bases: sphinx.ext.autodoc.importer._MockObject

Layer to create a heatmap from a given set of landmarks

Parameters:
  • img_size (tuple) – the image size of the returned heatmap
  • patch_size (int) – the patchsize to use
draw_landmarks(landmarks)[source]

Draws a group of landmarks

Parameters:landmarks (torch.Tensor) – the landmarks to draw (of shape Num_Landmarks x 2)
Returns:the heatmap containing all landmarks (of shape 1 x self.img_shape[0] x self.img_shape[1])
Return type:torch.Tensor
draw_lmk_helper(landmark)[source]

Draws a single point only

Parameters:landmark (torch.Tensor) – the landmarkto draw (of shape 1x2)
Returns:the heatmap containing one landmark (of shape 1 x self.img_shape[0] x self.img_shape[1])
Return type:torch.Tensor
forward(landmark_batch)[source]

Draws all landmarks from one batch element in one heatmap

Parameters:landmark_batch (torch.Tensor) – the landmarks to draw (of shape N x Num_landmarks x 2))
Returns:a batch of heatmaps (of shape N x 1 x self.img_shape[0] x self.img_shape[1])
Return type:torch.Tensor