Make the cv2 dependency optional (#27780)

Signed-off-by: Jacob <cmpute@qq.com>
This commit is contained in:
Jacob Zhong 2025-11-06 13:08:55 +08:00 committed by GitHub
parent 80679f108f
commit d72299d47b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -30,7 +30,6 @@ from io import BytesIO
from tempfile import NamedTemporaryFile
from typing import Any, cast
import cv2
import numpy as np
from PIL import Image
from transformers import PreTrainedTokenizerBase
@ -850,6 +849,8 @@ class RandomMultiModalDataset(RandomDataset):
Creates a video with random pixel values, encodes it to MP4 format,
and returns the content as bytes.
"""
import cv2
random_pixels = self._rng.integers(
0,
256,