Unverified Commit 3132aac0 authored by Jee Jee Li's avatar Jee Jee Li Committed by GitHub
Browse files

[Bugfix] Fix Idefics3 bug (#10778)


Signed-off-by: default avatarJee Jee Li <pandaleefree@gmail.com>
parent c82b432d
......@@ -267,7 +267,11 @@ def input_processor_for_idefics3(ctx: InputContext,
n_images_in_text = []
text = inputs.get("prompt")
if text is not None:
if text is None:
prompt_token_ids = inputs.get("prompt_token_ids", [])
assert prompt_token_ids
text = tokenizer.decode(prompt_token_ids)
if isinstance(text, str):
text = [text]
elif not isinstance(text, list) and not isinstance(text[0], str):
......@@ -279,8 +283,7 @@ def input_processor_for_idefics3(ctx: InputContext,
global_img_token = processor.global_image_tag
prompt_strings = []
for sample, sample_rows, sample_cols in zip(text, image_rows,
image_cols):
for sample, sample_rows, sample_cols in zip(text, image_rows, image_cols):
n_images_in_text.append(sample.count(image_token))
# Replace the image token with fake tokens around the expanded
......@@ -299,8 +302,7 @@ def input_processor_for_idefics3(ctx: InputContext,
split_sample = sample.split(image_token)
if len(split_sample) == 0:
raise ValueError(
"The image token should be present in the text.")
raise ValueError("The image token should be present in the text.")
# Place in the image prompt strings where the image tokens are
sample = split_sample[0]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment