2121 interpolate ,
2222)
2323
24- from ._meta import convert_format_bounding_box , get_dimensions_image_pil , get_dimensions_image_tensor
24+ from ._meta import (
25+ convert_format_bounding_box ,
26+ get_dimensions_image_tensor ,
27+ get_spatial_size_image_pil ,
28+ get_spatial_size_image_tensor ,
29+ )
2530
2631horizontal_flip_image_tensor = _FT .hflip
2732horizontal_flip_image_pil = _FP .hflip
@@ -323,7 +328,7 @@ def affine_image_pil(
323328 # it is visually better to estimate the center without 0.5 offset
324329 # otherwise image rotated by 90 degrees is shifted vs output image of torch.rot90 or F_t.affine
325330 if center is None :
326- _ , height , width = get_dimensions_image_pil (image )
331+ height , width = get_spatial_size_image_pil (image )
327332 center = [width * 0.5 , height * 0.5 ]
328333 matrix = _get_inverse_affine_matrix (center , angle , translate , scale , shear )
329334
@@ -1189,13 +1194,13 @@ def _center_crop_compute_crop_anchor(
11891194
11901195def center_crop_image_tensor (image : torch .Tensor , output_size : List [int ]) -> torch .Tensor :
11911196 crop_height , crop_width = _center_crop_parse_output_size (output_size )
1192- _ , image_height , image_width = get_dimensions_image_tensor (image )
1197+ image_height , image_width = get_spatial_size_image_tensor (image )
11931198
11941199 if crop_height > image_height or crop_width > image_width :
11951200 padding_ltrb = _center_crop_compute_padding (crop_height , crop_width , image_height , image_width )
11961201 image = pad_image_tensor (image , padding_ltrb , fill = 0 )
11971202
1198- _ , image_height , image_width = get_dimensions_image_tensor (image )
1203+ image_height , image_width = get_spatial_size_image_tensor (image )
11991204 if crop_width == image_width and crop_height == image_height :
12001205 return image
12011206
@@ -1206,13 +1211,13 @@ def center_crop_image_tensor(image: torch.Tensor, output_size: List[int]) -> tor
12061211@torch .jit .unused
12071212def center_crop_image_pil (image : PIL .Image .Image , output_size : List [int ]) -> PIL .Image .Image :
12081213 crop_height , crop_width = _center_crop_parse_output_size (output_size )
1209- _ , image_height , image_width = get_dimensions_image_pil (image )
1214+ image_height , image_width = get_spatial_size_image_pil (image )
12101215
12111216 if crop_height > image_height or crop_width > image_width :
12121217 padding_ltrb = _center_crop_compute_padding (crop_height , crop_width , image_height , image_width )
12131218 image = pad_image_pil (image , padding_ltrb , fill = 0 )
12141219
1215- _ , image_height , image_width = get_dimensions_image_pil (image )
1220+ image_height , image_width = get_spatial_size_image_pil (image )
12161221 if crop_width == image_width and crop_height == image_height :
12171222 return image
12181223
@@ -1365,7 +1370,7 @@ def five_crop_image_tensor(
13651370 image : torch .Tensor , size : List [int ]
13661371) -> Tuple [torch .Tensor , torch .Tensor , torch .Tensor , torch .Tensor , torch .Tensor ]:
13671372 crop_height , crop_width = _parse_five_crop_size (size )
1368- _ , image_height , image_width = get_dimensions_image_tensor (image )
1373+ image_height , image_width = get_spatial_size_image_tensor (image )
13691374
13701375 if crop_width > image_width or crop_height > image_height :
13711376 msg = "Requested crop size {} is bigger than input size {}"
@@ -1385,7 +1390,7 @@ def five_crop_image_pil(
13851390 image : PIL .Image .Image , size : List [int ]
13861391) -> Tuple [PIL .Image .Image , PIL .Image .Image , PIL .Image .Image , PIL .Image .Image , PIL .Image .Image ]:
13871392 crop_height , crop_width = _parse_five_crop_size (size )
1388- _ , image_height , image_width = get_dimensions_image_pil (image )
1393+ image_height , image_width = get_spatial_size_image_pil (image )
13891394
13901395 if crop_width > image_width or crop_height > image_height :
13911396 msg = "Requested crop size {} is bigger than input size {}"
0 commit comments