Tensorflow

Transforms

class ToTensorflow(always_apply=True, p=1.0)[source]

Bases: BasicTransform

Convert image and mask to Tensorflow.Tensor. The numpy HWDC image is converted to Tensorflow HWDC tensor. If the image is in HWD format (grayscale image), it will be converted to Tensorflow HWDC tensor.

Parameters:
  • always_apply (bool) – Indicates whether this transformation should be always applied. Default: True.

  • p (float) – Probability of applying the transform. Default: 1.0.

apply(img: ndarray, **params) tf.tensor[source]

Applies the transformation to the image

apply_to_mask(mask: ndarray, **params) tf.tensor[source]

Applies the augmentation to a mask

apply_to_masks(masks: List[ndarray], **params) tf.tensor[source]
get_params_dependent_on_targets(params: Dict[str, Any]) Dict[str, Any][source]

Returns additional parameters needed for the apply methods that depend on a target (e.g. apply_to_bboxes method expects image size)

get_transform_init_args_names() Tuple[str, ...][source]

Returns initialization argument names. (e.g. Transform(arg1 = 1, arg2 = 2) -> (‘arg1’, ‘arg2’))

property targets: Dict[str, Callable]

Returns the mapping of target to applicable apply method. (e.g. {‘image’: self.apply, ‘bboxes’, self.apply_to_bboxes})