crumpets.torch.augmentation_cuda module

crumpets.torch.augmentation_cuda.add_blur(im, augs)[source]

A Function that takes a tensor that contains a batch of images and a list of dictionaries that contain information about the desired blur and takes this information to blur the image.

This function is hardware accelerated, so be sure that the im is located on the GPU.

Parameters
  • im – the Tensor that contains the image data

  • augs – a list of dictionaries. Each dict should contain a ‘blur’ value. This blur indicates the sigma value of the normal distribution filter that is used to blur the image. Also note that the blur value should be relative to the image size, to achieve the same optical blur effect on different image sizes. For further information see randomize_image()

crumpets.torch.augmentation_cuda.add_gamma(im_tensor, augs, maxv=None)[source]

A Function that takes a tensor that contains a Batch of Images and a list of dictionaries that contain information about the desired gamma values and takes those gamma values to apply gamma correction to the images. This function is hardware accelerated, so be sure that the im_tensor is located on the GPU.

Parameters
  • im_tensor – the Tensor that contains the Image data

  • augs – a list of dictionaries. Each dict should contain a ‘color’, a ‘gamma_gray’, a ‘gamma_color’, and a ‘contrast’ value to specify the behaviour of the gamma augmentation. For further information see randomize_image()

  • maxv – Maximum value of the entries. This value is data type dependent, so be careful with it. It defaults to “None”. None indicates that the value is taken according to the data type of the tensor.

crumpets.torch.augmentation_cuda.add_noise_other(im, augs, minv=None, maxv=None, internal_ftype=None)[source]

A Function that takes a tensor that contains a batch of images and a list of dictionaries that contain information about the desired noise and adds noise according to that to the images.

This function is Hardware accelerated, so be sure that the im tensor is located on the GPU.

Parameters
  • im – the Tensor that contains the image data

  • augs – a list of dictionaries. Each dict should contain a ‘noise’ value to specify the behaviour of the noise augmentation. For further information see randomize_image()

  • minv – Minimum value of the entries. This value is data type dependent, so be careful with it. It defaults to “None”. None indicates that the value is taken according to the data type of the tensor.

  • maxv – Maximum value of the entries. This value is data type dependent, so be careful with it. It defaults to “None”. None indicates that the value is taken according to the data type of the tensor.

  • internal_ftype – The type that is used internally to compute the noise. For most types the internal type is float32. The type defaults to None, what indicates that a fitting type is chosen according to the input type.

crumpets.torch.augmentation_cuda.add_noise_rgb(im, augs, minv=None, maxv=None, internal_ftype=None)[source]

A Function that takes a tensor that contains a batch of images and a list of dictionaries that contain information about the desired noise and takes this information to add noise according to the that to the images.

This noise function tries to mimic the rgb noise of a camera sensor, what means that the green value has a lower noise.

This function is hardware accelerated, so be sure that the im is located on the GPU.

Parameters
  • im – the Tensor that contains the Image data

  • augs – a list of dictionaries. Each dict should contain a ‘noise’ value to specify the behaviour of the noise augmentation. For further information see randomize_image()

  • minv – Minimum value of the entries. This value is data type dependent, so be careful with it. It defaults to “None”. None indicates that the value is taken according to the data type of the tensor.

  • maxv – Maximum value of the entries. This value is data type dependent, so be careful with it. It defaults to “None”. None indicates that the value is taken according to the data type of the tensor.

  • internal_ftype – The type that is used internally to compute the noise. The type defaults to None, what indicates that a fitting type is chosen according to the input type. For most types the internal type is float32.