Skip to content

Commit

Permalink
Relax requirement for patch size and config for llava preprocessor (#…
Browse files Browse the repository at this point in the history
…1142)

* relax requirement for patch size and config for llava preprocessor

* Update optimum/intel/openvino/modeling_visual_language.py
  • Loading branch information
eaidova authored Feb 5, 2025
1 parent 588738d commit 61a74cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions optimum/exporters/openvino/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,14 @@ def save_preprocessors(
if is_transformers_version(">=", "4.45") and model_type == "phi3-v" and len(preprocessors) > 1:
if not hasattr(preprocessors[1], "chat_template"):
preprocessors[1].chat_template = getattr(preprocessors[0], "chat_template", None)
if (
is_transformers_version(">=", "4.45")
and model_type in ["llava", "llava-next"]
and preprocessors is not None
):
if getattr(preprocessors[1], "patch_size", None) is None:
preprocessors[1].patch_size = config.vision_config.patch_size
preprocessors[1].vision_feature_select_strategy = config.vision_feature_select_strategy
for processor in preprocessors:
try:
processor.save_pretrained(output)
Expand Down
2 changes: 1 addition & 1 deletion optimum/intel/openvino/modeling_visual_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ def preprocess_inputs(
else:
prompt = text

if getattr(processor, "patch_size", None) is None:
if is_transformers_version(">", "4.47.99") and getattr(processor, "patch_size", None) is None:
if (
getattr(config, "vision_config", None) is not None
and getattr(config.vision_config, "patch_size", None) is not None
Expand Down

0 comments on commit 61a74cd

Please sign in to comment.