File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed
Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 22# Copyright (C) 2023-2025 Intel Corporation
33# SPDX-License-Identifier: Apache-2.0
44
5+
6+ import os
7+ import cv2
58from .model_utils import get_param_from_file
69from .parse_json_data import parse_text_json_data
710
8-
911def get_text_prompt (args ):
1012 text_list = []
1113 output_data_list , is_json_data = get_param_from_file (args , 'prompt' )
@@ -17,3 +19,10 @@ def get_text_prompt(args):
1719 else :
1820 text_list .append (output_data_list [0 ])
1921 return text_list
22+
23+
24+ def split_video_into_frames (video_path ):
25+ supported_files = set ([".mp4" ])
26+ assert os .path .exists (video_path ), "no input video file"
27+ assert video_path .suffix .lower () in supported_files , "no supported video file"
28+ cap = cv2 .VideoCapture (video_path )
Original file line number Diff line number Diff line change @@ -18,3 +18,4 @@ librosa # For Whisper
1818matplotlib
1919jinja2 >= 3.1.0
2020scipy
21+ opencv-python
Original file line number Diff line number Diff line change 1717import llm_bench_utils .output_file
1818import llm_bench_utils .gen_output_data as gen_output_data
1919import llm_bench_utils .parse_json_data as parse_json_data
20+ import llm_bench_utils .prompt_utils as pu
2021from pathlib import Path
2122
22-
2323FW_UTILS = {'pt' : llm_bench_utils .pt_utils , 'ov' : llm_bench_utils .ov_utils }
2424
2525DEFAULT_OUTPUT_TOKEN_SIZE = 512
@@ -44,6 +44,12 @@ def run_visual_language_generation_optimum(
4444 images .append (load_image (str (file )))
4545 else :
4646 images .append (load_image (input_data ["media" ]))
47+
48+ if input_data .get ("video" , None ):
49+ entry = Path (input_data ["video" ])
50+ ordered_frames = pu .split_video_into_frames (entry )
51+ images .extend (ordered_frames )
52+
4753 prompts .append (input_data ["prompt" ])
4854 prefix = '[warm-up]' if num == 0 else '[{}]' .format (num )
4955 log .info (f'{ prefix } [P{ prompt_index } ] Input image nums:{ len (images )} ' )
You can’t perform that action at this time.
0 commit comments