File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 55from functools import lru_cache
66from typing import Any , ClassVar , Literal
77
8- import cv2
98import numpy as np
109import numpy .typing as npt
1110from huggingface_hub import hf_hub_download
@@ -43,6 +42,8 @@ def download_video_asset(filename: str) -> str:
4342
4443
4544def video_to_ndarrays (path : str , num_frames : int = - 1 ) -> npt .NDArray :
45+ import cv2
46+
4647 cap = cv2 .VideoCapture (path )
4748 if not cap .isOpened ():
4849 raise ValueError (f"Could not open video file { path } " )
@@ -78,6 +79,8 @@ def video_to_pil_images_list(path: str, num_frames: int = -1) -> list[Image.Imag
7879
7980
8081def video_get_metadata (path : str , num_frames : int = - 1 ) -> dict [str , Any ]:
82+ import cv2
83+
8184 cap = cv2 .VideoCapture (path )
8285 if not cap .isOpened ():
8386 raise ValueError (f"Could not open video file { path } " )
You can’t perform that action at this time.
0 commit comments