Skip to content

Commit 5e732da

Browse files
committed
Update optimum/intel/openvino/modeling_visual_language.py
1 parent 7316d4e commit 5e732da

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

optimum/intel/openvino/modeling_visual_language.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1426,15 +1426,17 @@ def load_image(image, input_size=448, max_num=12):
14261426
pixel_values = [transform(image) for image in images]
14271427
pixel_values = torch.stack(pixel_values)
14281428
return pixel_values
1429-
1429+
14301430
if image is not None and "<image>" not in text:
14311431
text = "<image>\n" + text
14321432

14331433
if tokenizer.chat_template is not None:
1434-
text = tokenizer.apply_chat_template([{"role": "user", "content": text}], add_generation_prompt=True, tokenize=False)
1435-
1434+
text = tokenizer.apply_chat_template(
1435+
[{"role": "user", "content": text}], add_generation_prompt=True, tokenize=False
1436+
)
1437+
14361438
inputs = {}
1437-
1439+
14381440
if image is not None:
14391441
if config is None:
14401442
raise ValueError("Config is required.")
@@ -1446,7 +1448,6 @@ def load_image(image, input_size=448, max_num=12):
14461448
)
14471449
image_tokens = IMG_START_TOKEN + IMG_CONTEXT_TOKEN * num_image_token * num_patches + IMG_END_TOKEN
14481450
text = text.replace("<image>", image_tokens, 1)
1449-
logger.warn(text)
14501451
inputs.update({"pixel_values": pixel_values})
14511452
inputs.update(tokenizer(text, return_tensors="pt"))
14521453
return inputs

0 commit comments

Comments
 (0)