Skip to content

Commit 55cca3c

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

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-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

tests/openvino/test_modeling.py

+4
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,10 @@ def test_beam_search(self, model_arch):
13151315
if model_arch in ["qwen", "chatglm", "glm4"]:
13161316
return
13171317

1318+
# TODO: add back once https://huggingface.co/katuni4ka/tiny-random-minicpm3/discussions/1 merged (for all models) as current mdoeling incompatible with transformers >= v4.49
1319+
if model_arch in {"deepseek"} and is_transformers_version(">=", "4.49"):
1320+
self.skipTest("Incompatible modeling code")
1321+
13181322
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=model_arch in self.REMOTE_CODE_MODELS)
13191323
if model_arch == "persimmon":
13201324
tokenizer.pad_token_id = tokenizer.bos_token_id

0 commit comments

Comments
 (0)