ocl.utils.resizing
Utilities related to resizing of tensors.
Resize
Module resizing tensors.
Source code in ocl/utils/resizing.py
forward
Resize tensor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input |
torch.Tensor
|
Tensor to resize. If |
required |
size_tensor |
Optional[torch.Tensor]
|
Tensor which size to resize to. If tensor has <=2 dimensions and the last dimension of this tensor has length 2, the two entries are taken as height and width. Otherwise, the size of the last two dimensions of this tensor are used as height and width. |
None
|
Tensor of shape (..., C, H, W), where height and width are either specified by
Type | Description |
---|---|
torch.Tensor
|
|
Source code in ocl/utils/resizing.py
resize_patches_to_image
Convert and resize a tensor of patches to image shape.
This method requires that the patches can be converted to a square image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
patches |
torch.Tensor
|
Patches to be converted of shape (..., C, P), where C is the number of channels and P the number of patches. |
required |
size |
Optional[int]
|
Image size to resize to. |
None
|
scale_factor |
Optional[float]
|
Scale factor by which to resize the patches. Can be specified alternatively to
|
None
|
resize_mode |
str
|
Method to resize with. Valid options are "nearest", "nearest-exact", "bilinear", "bicubic". |
'bilinear'
|
Returns:
Type | Description |
---|---|
torch.Tensor
|
Tensor of shape (..., C, S, S) where S is the image size. |