@@ -467,17 +467,17 @@ def _resize_and_crop(
467
467
468
468
def resize (
469
469
self ,
470
- image : Union [ PIL . Image . Image , np . ndarray , torch . Tensor ] ,
470
+ image : PipelineImageInput ,
471
471
height : int ,
472
472
width : int ,
473
473
resize_mode : str = "default" , # "default", "fill", "crop"
474
- ) -> Union [ PIL . Image . Image , np . ndarray , torch . Tensor ] :
474
+ ) -> PipelineImageInput :
475
475
"""
476
476
Resize image.
477
477
478
478
Args:
479
- image (`PIL.Image.Image`, `np.ndarray` or ` torch.Tensor`):
480
- The image input, can be a PIL image, numpy array or pytorch tensor.
479
+ image (`torch.Tensor`, ` PIL.Image.Image`, `np.ndarray`, `List[ torch.Tensor]`, `List[PIL.Image.Image]`, or `List[np.ndarray] `):
480
+ The image batch input, can be a PIL image, numpy array or pytorch tensor, or a list of these elements .
481
481
height (`int`):
482
482
The height to resize to.
483
483
width (`int`):
@@ -492,7 +492,7 @@ def resize(
492
492
supported for PIL image input.
493
493
494
494
Returns:
495
- `PIL.Image.Image`, `np.ndarray` or ` torch.Tensor`:
495
+ `torch.Tensor`, ` PIL.Image.Image`, `np.ndarray`, `List[ torch.Tensor]`, `List[PIL.Image.Image]`, or `List[np.ndarray] `:
496
496
The resized image.
497
497
"""
498
498
if resize_mode != "default" and not isinstance (image , PIL .Image .Image ):
@@ -523,6 +523,16 @@ def resize(
523
523
size = (height , width ),
524
524
)
525
525
image = self .pt_to_numpy (image )
526
+ elif isinstance (image , list ):
527
+ image = [
528
+ self .resize (
529
+ img ,
530
+ height = height ,
531
+ width = width ,
532
+ resize_mode = resize_mode ,
533
+ )
534
+ for img in image
535
+ ]
526
536
return image
527
537
528
538
def binarize (self , image : PIL .Image .Image ) -> PIL .Image .Image :
0 commit comments