[Bugfix][Security] Guard _load_ov2_processor with resolve_trust_remote_code (#52952)
Signed-off-by: jperezde <jperezde@redhat.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user