ResizeByLongerSide: support video

(cherry picked from commit 98c6840aa4e5fd5407ba9ab113d209011e474bf6)
This commit is contained in:
tavihalperin 2025-12-29 15:47:10 +02:00
parent 8fd07170f1
commit f48e70c29e

View File

@ -667,7 +667,9 @@ class ResizeImagesByLongerEdgeNode(ImageProcessingNode):
@classmethod @classmethod
def _process(cls, image, longer_edge): def _process(cls, image, longer_edge):
img = tensor_to_pil(image) resized_images = []
for image_i in image:
img = tensor_to_pil(image_i)
w, h = img.size w, h = img.size
if w > h: if w > h:
new_w = longer_edge new_w = longer_edge
@ -676,7 +678,8 @@ class ResizeImagesByLongerEdgeNode(ImageProcessingNode):
new_h = longer_edge new_h = longer_edge
new_w = int(w * (longer_edge / h)) new_w = int(w * (longer_edge / h))
img = img.resize((new_w, new_h), Image.Resampling.LANCZOS) img = img.resize((new_w, new_h), Image.Resampling.LANCZOS)
return pil_to_tensor(img) resized_images.append(pil_to_tensor(img))
return torch.cat(resized_images, dim=0)
class CenterCropImagesNode(ImageProcessingNode): class CenterCropImagesNode(ImageProcessingNode):