@@ -56,6 +56,7 @@ def __init__(
5656 system_prompt : Optional [str ] = None ,
5757 interleave_visuals : Optional [bool ] = False ,
5858 reasoning_prompt : Optional [str ] = None ,
59+ trust_remote_code : Optional [bool ] = False ,
5960 ** kwargs ,
6061 ) -> None :
6162 super ().__init__ ()
@@ -86,24 +87,25 @@ def __init__(
8687 if attn_implementation is not None :
8788 model_kwargs ["attn_implementation" ] = attn_implementation
8889
89- config = AutoConfig .from_pretrained (pretrained )
90+ self .trust_remote_code = trust_remote_code
91+ config = AutoConfig .from_pretrained (pretrained , trust_remote_code = trust_remote_code )
9092 if config .model_type in AutoModelForCausalLM ._model_mapping .keys ():
9193 model_cls = AutoModelForCausalLM
9294 elif config .model_type in AutoModelForImageTextToText ._model_mapping .keys ():
9395 model_cls = AutoModelForImageTextToText
9496 else :
9597 model_cls = AutoModel
9698
97- self ._model = model_cls .from_pretrained (pretrained , ** model_kwargs ).eval ()
99+ self ._model = model_cls .from_pretrained (pretrained , trust_remote_code = trust_remote_code , ** model_kwargs ).eval ()
98100 self .max_num_frames = max_num_frames
99101
100102 raw_prompt = reasoning_prompt or system_prompt
101103 if raw_prompt :
102104 self .system_prompt = self ._resolve_system_prompt (raw_prompt .replace ("\\ n" , "\n " ))
103105 else :
104106 self .system_prompt = None
105- self .processor = AutoProcessor .from_pretrained (pretrained )
106- self ._tokenizer = AutoTokenizer .from_pretrained (pretrained )
107+ self .processor = AutoProcessor .from_pretrained (pretrained , trust_remote_code = trust_remote_code )
108+ self ._tokenizer = AutoTokenizer .from_pretrained (pretrained , trust_remote_code = trust_remote_code )
107109 self .interleave_visuals = interleave_visuals
108110
109111 self ._config = self .model .config
0 commit comments