Image Utilities¶
This module holds functionality related to loading and saving images.
-
stransfer.img_utils.
concat_images
(im1, im2, dim=2)[source]¶ Simple wrapper function that concatenates two images along a given dimension.
- Parameters
im1 –
im2 –
dim – the dimension we want to concatenate across. By default it is the third dimension (width if images only have 3 dims)
- Return type
- Returns
tensor representing concatenated image
-
stransfer.img_utils.
image_loader
(image_path)[source]¶ Loads an image from image_path, and transforms it into a torch.Tensor
-
stransfer.img_utils.
image_loader_transform
(image)[source]¶ Transform a PIL.Image instance into a torch.Tensor one.
- Parameters
image (<module 'PIL.Image' from '/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/PIL/Image.py'>) – image to transform
- Return type
- Returns
torch.Tensor representing the image
-
stransfer.img_utils.
imshow
(image_tensor, ground_truth_image=None, denormalize=True, path='out.bmp')[source]¶ Utility function to save an input image tensor to disk.
- Parameters
image_tensor (
Tensor
) – the tensor representing the image to be savedground_truth_image (
Optional
[Tensor
]) – another tensor, representing another image. If provided, it will be concatenated to the image_tensor across the width dimension and this result will be saved to diskdenormalize – whether or not to denormalize (using IMAGENET mean and std) the tensor before saving it to disk.
path – the path where the image will be saved
- Return type
None