image_transforms

Description

Transformations to images. The images are assumed to be a torch.Tensor of a PIL.Image.Image. Use torchvision.transforms.ToTensor to transform PIL.Image.Image instances appropriately.

Classes

AsBatch

Ensure that the given transformation is fed with a batch of inputs.

BatchWiseImageTransform

Wrap a transformation operating on a batch of masks to also work on single masks.

Binarize

Simple class for binarizing tensors into high and low class values.

BinarizeByQuantile

Set all but the given highest number of pixels / q-th quantile in an image to zero, rest to 1.

ConvOpWrapper

Base wrapper class to turn convolutional batch operations into single mask operations.

ImageTransform

Transformations that can be applied to images.

IntersectDecode

IoU encode a single mask.

IntersectEncode

Intersection encode a single mask.

IoUEncode

IoU encode a single mask.

NoGrad

Disable requires_grad for the given tensors.

PadAndResize

Transformation that pads an image to a given ratio and then resizes it to fixed size.

RecursiveLambda

Generic lambda transformation that applies the given function with the standard ImageTransform recursion.

Resize

Simple resize.

Threshold

Threshold tensors and set new values below and/or above the threshold.

ToActMap

Evaluate a given image by a torch model on the correct device.

ToBBoxes

Treat pixels of given mask as scores of constant-size bounding boxes, and return a mask with the non-max-suppressed bounding boxes.

ToFixedDims

Squeeze or unsqueeze a tensor to obtain specified number of dimensions.

ToTensor

Turn objects into tensors or move tensors to given device or dtype.

WithThresh

Wrap a batch transformation with binarizing (and unsqueezing) before and after.

Functions

pad_and_resize(img, img_size[, interpolation])

Pad and resize an image.

pad_to_ratio(img_t[, ratio, pad_value])

Pad image with constant pad_value to obtain given image size ratio.

padding_for_ratio(from_size, to_ratio)

Return the int padding for an image of size (height, width) to get a (width / height) ratio of ratio.

resize(tens, size[, mode])

Resize the given tensor assuming it to be a 2D image or batch thereof.