Skip to content

Commit c8133d8

Browse files
authored
Support batch processing for whisper example (#1723)
1 parent 4921ae8 commit c8133d8

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

benchmark/python/benchmark_multimodal.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ def run_benchmark(args, model, processor, image, audio, generation_length, max_l
157157
main_prompt = "What is the meaning of life?"
158158
prompt = f'{user_prompt}{main_prompt}{prompt_suffix}{assistant_prompt}'
159159

160-
prompts = [prompt]
160+
if model_type == "whisper":
161+
decoder_prompt_tokens = ["<|startoftranscript|>", "<|en|>", "<|transcribe|>", "<|notimestamps|>"]
162+
prompts = ["".join(decoder_prompt_tokens)]
163+
else:
164+
prompts = [prompt]
161165
inputs = processor(prompts, images=image, audios=audio)
162166
prompt_length = inputs['input_ids'].shape()[1]
163167
if args.verbose: print(f"Prompt used: {prompt}")

examples/python/whisper.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def run(args: argparse.Namespace):
3636
readline.set_completer(_complete)
3737

3838
if args.non_interactive:
39-
audio_paths = [args.audio]
39+
audio_paths = [audio_path.strip() for audio_path in args.audio.split(",")]
4040
else:
4141
audio_paths = [audio_path.strip() for audio_path in input("Audio Paths (comma separated): ").split(",")]
4242
if len(audio_paths) == 0:
@@ -60,6 +60,7 @@ def run(args: argparse.Namespace):
6060
num_beams=args.num_beams,
6161
num_return_sequences=args.num_beams,
6262
max_length=448,
63+
batch_size=batch_size,
6364
)
6465

6566
generator = og.Generator(model, params)

0 commit comments

Comments
 (0)