Skip to content

Commit 1b26b17

Browse files
committed
kcz/add_mp4_disabling_into_frames
1 parent b6a87e5 commit 1b26b17

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

tools/llm_bench/llm_bench_utils/prompt_utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
# Copyright (C) 2023-2025 Intel Corporation
33
# SPDX-License-Identifier: Apache-2.0
44

5+
6+
import os
7+
import cv2
58
from .model_utils import get_param_from_file
69
from .parse_json_data import parse_text_json_data
710

8-
911
def 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)

tools/llm_bench/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ librosa # For Whisper
1818
matplotlib
1919
jinja2>=3.1.0
2020
scipy
21+
opencv-python

tools/llm_bench/task/visual_language_generation.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
import llm_bench_utils.output_file
1818
import llm_bench_utils.gen_output_data as gen_output_data
1919
import llm_bench_utils.parse_json_data as parse_json_data
20+
import llm_bench_utils.prompt_utils as pu
2021
from pathlib import Path
2122

22-
2323
FW_UTILS = {'pt': llm_bench_utils.pt_utils, 'ov': llm_bench_utils.ov_utils}
2424

2525
DEFAULT_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)}')

0 commit comments

Comments
 (0)