Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[llm_bench] Fix way with relative path of media for json prompts #1843

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tools/llm_bench/llm_bench_utils/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,11 @@ def init_timestamp(num_iters, prompt_list, prompt_idx_list):
p_idx = prompt_idx_list[idx]
iter_timestamp[num][p_idx] = {}
return iter_timestamp


def resolve_media_file_path(file_path, prompt_file_path):
if not file_path:
return file_path
if not (file_path.startswith("http://") or file_path.startswith("https://")):
return os.path.join(os.path.dirname(prompt_file_path), file_path.replace("./", ""))
return file_path
3 changes: 3 additions & 0 deletions tools/llm_bench/task/image_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ def get_image_prompt(args):
image_param_list = parse_json_data.parse_image_json_data(output_data_list)
if len(image_param_list) > 0:
for image_data in image_param_list:
if args['prompt_file'] is not None and len(args['prompt_file']) > 0:
image_data['media'] = model_utils.resolve_media_file_path(image_data.get("media"), args['prompt_file'][0])
image_data['mask_image'] = model_utils.resolve_media_file_path(image_data.get("mask_image"), args['prompt_file'][0])
input_image_list.append(image_data)
else:
input_image_list.append(output_data_list[0])
Expand Down
5 changes: 1 addition & 4 deletions tools/llm_bench/task/visual_language_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,7 @@ def get_image_text_prompt(args):
if len(vlm_param_list) > 0:
for vlm_file in vlm_param_list:
if args['prompt_file'] is not None and len(args['prompt_file']) > 0:
media_path = vlm_file["media"]
if not (media_path.startswith("http://") or media_path.startswith("https://")):
media_path = os.path.join(os.path.dirname(args['prompt_file'][0]), media_path.replace("./", ""))
vlm_file['media'] = media_path
vlm_file['media'] = model_utils.resolve_media_file_path(vlm_file.get("media"), args['prompt_file'][0])
vlm_file_list.append(vlm_file)
else:
vlm_file_list.append(output_data_list)
Expand Down
Loading