@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / efdef57b1f
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 14, 05:30 UTC

[bugfix] Lazy import cv2 (#26869)

Signed-off-by: angelayi <yiangela7@gmail.com>

Angela Yi committed Oct 15, 2025 at 00:47 UTC efdef57b1fefab62db76ff31053de9c185dbaf66
1 file changed +4 -1
vllm/assets/video.py
+4 -1
@@ -5,7 +5,6 @@ from dataclasses import dataclass
5 from functools import lru_cache
6 from typing import Any, ClassVar, Literal
7
8 -import cv2
8 import numpy as np
9 import numpy.typing as npt
10 from huggingface_hub import hf_hub_download
@@ -43,6 +42,8 @@ def download_video_asset(filename: str) -> str:
42
43
44 def video_to_ndarrays(path: str, num_frames: int = -1) -> npt.NDArray:
45 + import cv2
46 +
47 cap = cv2.VideoCapture(path)
48 if not cap.isOpened():
49 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
79
80
81 def video_get_metadata(path: str, num_frames: int = -1) -> dict[str, Any]:
82 + import cv2
83 +
84 cap = cv2.VideoCapture(path)
85 if not cap.isOpened():
86 raise ValueError(f"Could not open video file {path}")