@@ -467,17 +467,17 @@ def _resize_and_crop(
467467
468468 def resize (
469469 self ,
470- image : Union [ PIL . Image . Image , np . ndarray , torch . Tensor ] ,
470+ image : PipelineImageInput ,
471471 height : int ,
472472 width : int ,
473473 resize_mode : str = "default" , # "default", "fill", "crop"
474- ) -> Union [ PIL . Image . Image , np . ndarray , torch . Tensor ] :
474+ ) -> PipelineImageInput :
475475 """
476476 Resize image.
477477
478478 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 .
481481 height (`int`):
482482 The height to resize to.
483483 width (`int`):
@@ -492,7 +492,7 @@ def resize(
492492 supported for PIL image input.
493493
494494 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] `:
496496 The resized image.
497497 """
498498 if resize_mode != "default" and not isinstance (image , PIL .Image .Image ):
@@ -523,6 +523,16 @@ def resize(
523523 size = (height , width ),
524524 )
525525 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+ ]
526536 return image
527537
528538 def binarize (self , image : PIL .Image .Image ) -> PIL .Image .Image :
0 commit comments