21
21
interpolate ,
22
22
)
23
23
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
+ )
25
30
26
31
horizontal_flip_image_tensor = _FT .hflip
27
32
horizontal_flip_image_pil = _FP .hflip
@@ -323,7 +328,7 @@ def affine_image_pil(
323
328
# it is visually better to estimate the center without 0.5 offset
324
329
# otherwise image rotated by 90 degrees is shifted vs output image of torch.rot90 or F_t.affine
325
330
if center is None :
326
- _ , height , width = get_dimensions_image_pil (image )
331
+ height , width = get_spatial_size_image_pil (image )
327
332
center = [width * 0.5 , height * 0.5 ]
328
333
matrix = _get_inverse_affine_matrix (center , angle , translate , scale , shear )
329
334
@@ -1189,13 +1194,13 @@ def _center_crop_compute_crop_anchor(
1189
1194
1190
1195
def center_crop_image_tensor (image : torch .Tensor , output_size : List [int ]) -> torch .Tensor :
1191
1196
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 )
1193
1198
1194
1199
if crop_height > image_height or crop_width > image_width :
1195
1200
padding_ltrb = _center_crop_compute_padding (crop_height , crop_width , image_height , image_width )
1196
1201
image = pad_image_tensor (image , padding_ltrb , fill = 0 )
1197
1202
1198
- _ , image_height , image_width = get_dimensions_image_tensor (image )
1203
+ image_height , image_width = get_spatial_size_image_tensor (image )
1199
1204
if crop_width == image_width and crop_height == image_height :
1200
1205
return image
1201
1206
@@ -1206,13 +1211,13 @@ def center_crop_image_tensor(image: torch.Tensor, output_size: List[int]) -> tor
1206
1211
@torch .jit .unused
1207
1212
def center_crop_image_pil (image : PIL .Image .Image , output_size : List [int ]) -> PIL .Image .Image :
1208
1213
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 )
1210
1215
1211
1216
if crop_height > image_height or crop_width > image_width :
1212
1217
padding_ltrb = _center_crop_compute_padding (crop_height , crop_width , image_height , image_width )
1213
1218
image = pad_image_pil (image , padding_ltrb , fill = 0 )
1214
1219
1215
- _ , image_height , image_width = get_dimensions_image_pil (image )
1220
+ image_height , image_width = get_spatial_size_image_pil (image )
1216
1221
if crop_width == image_width and crop_height == image_height :
1217
1222
return image
1218
1223
@@ -1365,7 +1370,7 @@ def five_crop_image_tensor(
1365
1370
image : torch .Tensor , size : List [int ]
1366
1371
) -> Tuple [torch .Tensor , torch .Tensor , torch .Tensor , torch .Tensor , torch .Tensor ]:
1367
1372
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 )
1369
1374
1370
1375
if crop_width > image_width or crop_height > image_height :
1371
1376
msg = "Requested crop size {} is bigger than input size {}"
@@ -1385,7 +1390,7 @@ def five_crop_image_pil(
1385
1390
image : PIL .Image .Image , size : List [int ]
1386
1391
) -> Tuple [PIL .Image .Image , PIL .Image .Image , PIL .Image .Image , PIL .Image .Image , PIL .Image .Image ]:
1387
1392
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 )
1389
1394
1390
1395
if crop_width > image_width or crop_height > image_height :
1391
1396
msg = "Requested crop size {} is bigger than input size {}"
0 commit comments