jactorch.transforms.bbox.transforms#

Classes

Class CenterCrop

class CenterCrop[source]#

Bases: CenterCrop

__call__(img, bbox)[source]#

Call self as a function.

__init__(size)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(img)[source]#
Parameters:

img (PIL Image or Tensor) – Image to be cropped.

Returns:

Cropped image.

Return type:

PIL Image or Tensor

Class ColorJitter

class ColorJitter[source]#

Bases: ColorJitter

__call__(img, bbox)[source]#

Call self as a function.

__init__(brightness=0, contrast=0, saturation=0, hue=0)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

Parameters:
Return type:

None

forward(img)[source]#
Parameters:

img (PIL Image or Tensor) – Input image.

Returns:

Color jittered image.

Return type:

PIL Image or Tensor

static get_params(brightness, contrast, saturation, hue)[source]#

Get the parameters for the randomized transform to be applied on image.

Parameters:
  • brightness (tuple of float (min, max), optional) – The range from which the brightness_factor is chosen uniformly. Pass None to turn off the transformation.

  • contrast (tuple of float (min, max), optional) – The range from which the contrast_factor is chosen uniformly. Pass None to turn off the transformation.

  • saturation (tuple of float (min, max), optional) – The range from which the saturation_factor is chosen uniformly. Pass None to turn off the transformation.

  • hue (tuple of float (min, max), optional) – The range from which the hue_factor is chosen uniformly. Pass None to turn off the transformation.

Returns:

The parameters used to apply the randomized transform along with their random order.

Return type:

tuple

Class Compose

class Compose[source]#

Bases: Compose

__call__(img, bbox)[source]#

Call self as a function.

__init__(transforms)[source]#
__new__(**kwargs)#

Class DenormalizeBbox

class DenormalizeBbox[source]#

Bases: object

__call__(img, bbox)[source]#

Call self as a function.

__init__()#
__new__(**kwargs)#

Class Grayscale

class Grayscale[source]#

Bases: Grayscale

__call__(img, bbox)[source]#

Call self as a function.

__init__(num_output_channels=1)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(img)[source]#
Parameters:

img (PIL Image or Tensor) – Image to be converted to grayscale.

Returns:

Grayscaled image.

Return type:

PIL Image or Tensor

Class Lambda

class Lambda[source]#

Bases: Lambda

__call__(img, bbox)[source]#

Call self as a function.

__init__(lambd)[source]#
__new__(**kwargs)#

Class LinearTransformation

class LinearTransformation[source]#

Bases: LinearTransformation

__call__(tensor, bbox)[source]#

Call self as a function.

__init__(transformation_matrix, mean_vector)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(tensor)[source]#
Parameters:

tensor (Tensor) – Tensor image to be whitened.

Returns:

Transformed image.

Return type:

Tensor

Class Normalize

class Normalize[source]#

Bases: Normalize

__call__(img, bbox)[source]#

Call self as a function.

__init__(mean, std, inplace=False)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(tensor)[source]#
Parameters:

tensor (Tensor) – Tensor image to be normalized.

Returns:

Normalized Tensor image.

Return type:

Tensor

Class NormalizeBbox

class NormalizeBbox[source]#

Bases: object

__call__(img, bbox)[source]#

Call self as a function.

__init__()#
__new__(**kwargs)#

Class Pad

class Pad[source]#

Bases: Pad

__call__(img, bbox)[source]#

Call self as a function.

__init__(padding, fill=0, padding_mode='constant')[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(img)[source]#
Parameters:

img (PIL Image or Tensor) – Image to be padded.

Returns:

Padded image.

Return type:

PIL Image or Tensor

Class PadMultipleOf

class PadMultipleOf[source]#

Bases: PadMultipleOf

__call__(img, coor)[source]#

Call self as a function.

__init__(multiple, mode='constant', fill=0)[source]#
__new__(**kwargs)#

Class RandomCrop

class RandomCrop[source]#

Bases: RandomCrop

__call__(img, bbox)[source]#

Call self as a function.

__init__(size, padding=None, pad_if_needed=False, fill=0, padding_mode='constant')[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(img)[source]#
Parameters:

img (PIL Image or Tensor) – Image to be cropped.

Returns:

Cropped image.

Return type:

PIL Image or Tensor

static get_params(img, output_size)[source]#

Get parameters for crop for a random crop.

Parameters:
  • img (PIL Image or Tensor) – Image to be cropped.

  • output_size (tuple) – Expected output size of the crop.

Returns:

params (i, j, h, w) to be passed to crop for random crop.

Return type:

tuple

Class RandomGrayscale

class RandomGrayscale[source]#

Bases: RandomGrayscale

__call__(img, bbox)[source]#

Call self as a function.

__init__(p=0.1)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(img)[source]#
Parameters:

img (PIL Image or Tensor) – Image to be converted to grayscale.

Returns:

Randomly grayscaled image.

Return type:

PIL Image or Tensor

Class RandomHorizontalFlip

class RandomHorizontalFlip[source]#

Bases: RandomHorizontalFlip

__call__(img, bbox)[source]#

Call self as a function.

__init__(p=0.5)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(img)[source]#
Parameters:

img (PIL Image or Tensor) – Image to be flipped.

Returns:

Randomly flipped image.

Return type:

PIL Image or Tensor

Class RandomResizedCrop

class RandomResizedCrop[source]#

Bases: RandomResizedCrop

__call__(img, bbox)[source]#

Call self as a function.

__init__(size, scale=(0.08, 1.0), ratio=(3.0 / 4.0, 4.0 / 3.0), interpolation=InterpolationMode.BILINEAR, antialias=True)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

Parameters:

antialias (bool | None)

forward(img)[source]#
Parameters:

img (PIL Image or Tensor) – Image to be cropped and resized.

Returns:

Randomly cropped and resized image.

Return type:

PIL Image or Tensor

static get_params(img, scale, ratio)[source]#

Get parameters for crop for a random sized crop.

Parameters:
  • img (PIL Image or Tensor) – Input image.

  • scale (list) – range of scale of the origin size cropped

  • ratio (list) – range of aspect ratio of the origin aspect ratio cropped

Returns:

params (i, j, h, w) to be passed to crop for a random sized crop.

Return type:

tuple

Class RandomRotation

class RandomRotation[source]#

Bases: RandomRotation

__call__(img, bbox)[source]#

Call self as a function.

__init__(degrees, interpolation=InterpolationMode.NEAREST, expand=False, center=None, fill=0)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(img)[source]#
Parameters:

img (PIL Image or Tensor) – Image to be rotated.

Returns:

Rotated image.

Return type:

PIL Image or Tensor

static get_params(degrees)[source]#

Get parameters for rotate for a random rotation.

Returns:

angle parameter to be passed to rotate for random rotation.

Return type:

float

Parameters:

degrees (List[float])

Class RandomVerticalFlip

class RandomVerticalFlip[source]#

Bases: RandomVerticalFlip

__call__(img, bbox)[source]#

Call self as a function.

__init__(p=0.5)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(img)[source]#
Parameters:

img (PIL Image or Tensor) – Image to be flipped.

Returns:

Randomly flipped image.

Return type:

PIL Image or Tensor

Class Resize

class Resize[source]#

Bases: Resize

__call__(img, bbox)[source]#

Call self as a function.

__init__(size, interpolation=InterpolationMode.BILINEAR, max_size=None, antialias=True)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(img)[source]#
Parameters:

img (PIL Image or Tensor) – Image to be scaled.

Returns:

Rescaled image.

Return type:

PIL Image or Tensor

Class ToTensor

class ToTensor[source]#

Bases: ToTensor

__call__(img, bbox)[source]#
Parameters:

pic (PIL Image or numpy.ndarray) – Image to be converted to tensor.

Returns:

Converted image.

Return type:

Tensor

__init__()[source]#
Return type:

None

__new__(**kwargs)#