@@ -401,18 +401,16 @@ def pad_bounding_box(
401
401
) -> torch .Tensor :
402
402
left , _ , top , _ = _FT ._parse_pad_padding (padding )
403
403
404
- shape = bounding_box .shape
405
-
406
404
bounding_box = convert_bounding_box_format (
407
405
bounding_box , old_format = format , new_format = features .BoundingBoxFormat .XYXY
408
- ). view ( - 1 , 4 )
406
+ )
409
407
410
- bounding_box [: , 0 ::2 ] += left
411
- bounding_box [: , 1 ::2 ] += top
408
+ bounding_box [... , 0 ::2 ] += left
409
+ bounding_box [... , 1 ::2 ] += top
412
410
413
411
return convert_bounding_box_format (
414
412
bounding_box , old_format = features .BoundingBoxFormat .XYXY , new_format = format , copy = False
415
- ). view ( shape )
413
+ )
416
414
417
415
418
416
crop_image_tensor = _FT .crop
@@ -425,19 +423,17 @@ def crop_bounding_box(
425
423
top : int ,
426
424
left : int ,
427
425
) -> torch .Tensor :
428
- shape = bounding_box .shape
429
-
430
426
bounding_box = convert_bounding_box_format (
431
427
bounding_box , old_format = format , new_format = features .BoundingBoxFormat .XYXY
432
- ). view ( - 1 , 4 )
428
+ )
433
429
434
430
# Crop or implicit pad if left and/or top have negative values:
435
- bounding_box [: , 0 ::2 ] -= left
436
- bounding_box [: , 1 ::2 ] -= top
431
+ bounding_box [... , 0 ::2 ] -= left
432
+ bounding_box [... , 1 ::2 ] -= top
437
433
438
434
return convert_bounding_box_format (
439
435
bounding_box , old_format = features .BoundingBoxFormat .XYXY , new_format = format , copy = False
440
- ). view ( shape )
436
+ )
441
437
442
438
443
439
def crop_segmentation_mask (img : torch .Tensor , top : int , left : int , height : int , width : int ) -> torch .Tensor :
0 commit comments