Transforms¶
Transforms¶
-
class
torchelie.transforms.
ResizeNoCrop
(size)¶ Resize a PIL image so that its longer border is of size size
Parameters: size (int) – max size of the image
-
class
torchelie.transforms.
ResizedCrop
(size, scale=0.54, interpolation=2)¶ Crop the given PIL Image to size. A crop of size of the original size is made. This crop is finally resized to given size.
Parameters: - size – expected output size of each edge
- scale – size of the origin size cropped
- interpolation – Default: PIL.Image.BILINEAR
-
static
get_params
(img, scale)¶ Get parameters for
crop
. :param img: Image to be cropped. :type img: PIL Image :param scale: range of size of the origin size cropped :type scale: floatReturns: params (i, j, h, w) to be passed to crop
.Return type: tuple
-
class
torchelie.transforms.
AdaptPad
(sz, padding_mode='constant')¶ Pad an input image so that it reaches size size
Parameters: - sz ((int, int)) – target size
- padding_mode (str) – one of the modes of torchvision.transforms.pad
-
class
torchelie.transforms.
MultiBranch
(transforms)¶ Transform an image with multiple transforms
Parameters: transforms (list of transforms) – the parallel set of transforms
-
class
torchelie.transforms.
Canny
(thresh_low=100, thresh_high=200)¶ Run Canny edge detector over an image. Requires OpenCV to be installed
Parameters: - thresh_low (int) – lower threshold (default: 100)
- thresh_high (int) – upper threshold (default: 200)
Differentiable¶
-
torchelie.transforms.differentiable.
center_crop
(batch, size)¶ Crop the center of a 4D images tensor
Parameters: - batch (4D images tensor) – the tensor to crop
- size ((int, int)) – size of the resulting image as (height, width)
Returns: The cropped image
-
torchelie.transforms.differentiable.
crop
(img, warped=True, sub_img_factor=2)¶ Randomly crop a sub_img_factor smaller part of img.
Parameters: - img (3D or 4D image(s) tensor) – input image(s)
- warped (bool) – Whether the image should be considered warped (default: True)
- sub_img_factor (float) – fraction of the image to take. For instance, 2 will crop a quarter of the image (half the width, half the height). (default: 2)
-
torchelie.transforms.differentiable.
gblur
(input)¶ Gaussian blur with kernel size 3
Parameters: input (3D or 4D image(s) tensor) – input image Returns: the blurred tensor
-
torchelie.transforms.differentiable.
mblur
(input)¶ Mean (or average) blur with kernel size 3
Parameters: input (3D or 4D image(s) tensor) – input image Returns: the blurred tensor
-
torchelie.transforms.differentiable.
roll
(img, x_roll, y_roll)¶ Wrap an image
Parameters: - img (3D or 4D image(s) tensor) – an image tensor
- x_roll (int) – how many pixels to roll on the x axis
- y_roll (int) – how many pixels to roll on the y axis
Returns: The rolled tensor