simulation.utils.machine_learning.data.image_operations module

Summary

Functions:

save_image

Save a numpy image to the disk.

save_images

Save images to the disk.

tensor2im

Convert a Tensor array into a numpy image array.

Reference

tensor2im(input_image: torch.Tensor, img_type=<class 'numpy.uint8'>, to_rgb: bool = True) → numpy.ndarray[source]

Convert a Tensor array into a numpy image array.

Parameters
  • input_image (Tensor) – the input image tensor array

  • img_type (np.integer) – the desired type of the converted numpy array

  • to_rgb (bool) – translate gray image to rgb image

save_image(image_numpy: numpy.ndarray, image_path: str, aspect_ratio: float = 1.0) → None[source]

Save a numpy image to the disk.

Parameters
  • image_numpy (np.ndarray) – input numpy array

  • image_path (str) – the path of the image

  • aspect_ratio (float) – the aspect ratio of the resulting image

save_images(visuals: dict, destination: str, aspect_ratio: float = 1.0, post_fix: str = '') → None[source]

Save images to the disk.

This function will save images stored in ‘visuals’.

Parameters
  • destination – the folder to save the images to

  • visuals (dict) – an ordered dictionary that stores (name, images (either tensor or numpy) ) pairs

  • aspect_ratio (float) – the aspect ratio of saved images

  • post_fix (str) – The string that extends the prefix_path