[data] add forward compatibility for video_utils in Transformers 4.52.0 (#8077)

This commit is contained in:
Kingsley 2025-05-16 17:41:04 +08:00 committed by GitHub
parent 130bfaf8e3
commit 66f719dd96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -58,7 +58,18 @@ if is_transformers_version_greater_than("4.45.0"):
if is_transformers_version_greater_than("4.49.0"):
from transformers.image_utils import make_batched_videos, make_flat_list_of_images
try:
from transformers.image_utils import make_batched_videos, make_flat_list_of_images
except ImportError:
try:
# If that fails, try importing from the new location
from transformers.video_utils import make_batched_videos
from transformers.image_utils import make_flat_list_of_images
except ImportError:
raise ImportError(
"Could not import make_batched_videos and make_flat_list_of_images. "
"In Transformers 4.52.0, make_batched_videos will be moved to transformers.video_utils."
)
if TYPE_CHECKING: