[Bugfix][Security] Guard _load_ov2_processor with resolve_trust_remote_code (#52952)

Signed-off-by: jperezde <jperezde@redhat.com>
This commit is contained in:
Juan Pérez de Algaba
2026-08-20 09:09:49 +00:00
committed by GitHub
parent 963fcfa48c
commit c0a25c089a
+11 -3
View File
@@ -39,7 +39,10 @@ import torch.nn as nn
import torch.nn.functional as F
from PIL import Image
from transformers import AutoProcessor, AutoTokenizer, BatchFeature
from transformers.dynamic_module_utils import get_class_from_dynamic_module
from transformers.dynamic_module_utils import (
get_class_from_dynamic_module,
resolve_trust_remote_code,
)
from transformers.models.qwen2_vl import Qwen2VLImageProcessor
from transformers.models.qwen2_vl.image_processing_qwen2_vl import smart_resize
@@ -129,17 +132,22 @@ def _load_ov2_processor(
path = convert_model_repo_to_path(model)
revision = revision or "main"
resolve_trust_remote_code(
trust_remote_code,
model,
has_local_code=False,
has_remote_code=True,
)
processor_cls = get_class_from_dynamic_module(
"processing_llava_onevision2.LlavaOnevision2Processor",
path,
revision=revision,
trust_remote_code=trust_remote_code,
)
video_processor_cls = get_class_from_dynamic_module(
"video_processing_llava_onevision2.LlavaOnevision2VideoProcessor",
path,
revision=revision,
trust_remote_code=trust_remote_code,
)
# Slow Qwen2VLImageProcessor mirrors the remote processor (the Fast variant