@@ -19,7 +19,10 @@ def __init__(self, model, model_dir, model_type):
19
19
self .model_type = model_type
20
20
21
21
if model_type == "text" or model_type == "visual-text" :
22
- self .config = AutoConfig .from_pretrained (model_dir , trust_remote_code = True )
22
+ try :
23
+ self .config = AutoConfig .from_pretrained (model_dir , trust_remote_code = True )
24
+ except Exception :
25
+ self .config = AutoConfig .from_pretrained (model_dir )
23
26
elif model_type == "text-to-image" :
24
27
self .config = DiffusionPipeline .load_config (
25
28
model_dir , trust_remote_code = True )
@@ -101,17 +104,27 @@ def load_text_model(
101
104
model = OVModelForCausalLM .from_pretrained (
102
105
model_id , trust_remote_code = True , device = device , ov_config = ov_config
103
106
)
104
- except ValueError :
105
- config = AutoConfig .from_pretrained (
106
- model_id , trust_remote_code = True )
107
- model = OVModelForCausalLM .from_pretrained (
108
- model_id ,
109
- config = config ,
110
- trust_remote_code = True ,
111
- use_cache = True ,
112
- device = device ,
113
- ov_config = ov_config ,
114
- )
107
+ except Exception :
108
+ try :
109
+ config = AutoConfig .from_pretrained (
110
+ model_id , trust_remote_code = True )
111
+ model = OVModelForCausalLM .from_pretrained (
112
+ model_id ,
113
+ config = config ,
114
+ trust_remote_code = True ,
115
+ use_cache = True ,
116
+ device = device ,
117
+ ov_config = ov_config ,
118
+ )
119
+ except Exception :
120
+ config = AutoConfig .from_pretrained (model_id )
121
+ model = OVModelForCausalLM .from_pretrained (
122
+ model_id ,
123
+ config = config ,
124
+ use_cache = True ,
125
+ device = device ,
126
+ ov_config = ov_config ,
127
+ )
115
128
116
129
return model
117
130
0 commit comments