@@ -223,8 +223,16 @@ def _infer_supports_vision(self, model_id_or_path: str) -> None:
223
223
attribute based on whether the config has `vision_config`. All LVM models has
224
224
`vision_config` setup.
225
225
"""
226
- hf_config = transformers .PretrainedConfig .from_pretrained (model_id_or_path )
227
- self ._supports_vision = hasattr (hf_config , "vision_config" )
226
+ try :
227
+ hf_config = transformers .PretrainedConfig .from_pretrained (model_id_or_path )
228
+ self ._supports_vision = hasattr (hf_config , "vision_config" )
229
+ except Exception as e :
230
+ raise ValueError (
231
+ f"Failed to load Hugging Face config for model_id='{ model_id_or_path } '.\
232
+ Ensure `model_id` is a valid Hugging Face repo or a local path that \
233
+ contains a valid `config.json` file. "
234
+ f"Original error: { repr (e )} "
235
+ ) from e
228
236
229
237
def _set_model_architecture (
230
238
self ,
@@ -236,9 +244,23 @@ def _set_model_architecture(
236
244
attribute based on whether the config has `architectures`.
237
245
"""
238
246
if model_id_or_path :
239
- hf_config = transformers .PretrainedConfig .from_pretrained (model_id_or_path )
240
- if hasattr (hf_config , "architectures" ) and hf_config .architectures :
241
- self ._model_architecture = hf_config .architectures [0 ]
247
+ try :
248
+ hf_config = transformers .PretrainedConfig .from_pretrained (
249
+ model_id_or_path
250
+ )
251
+ if (
252
+ hf_config
253
+ and hasattr (hf_config , "architectures" )
254
+ and hf_config .architectures
255
+ ):
256
+ self ._model_architecture = hf_config .architectures [0 ]
257
+ except Exception as e :
258
+ raise ValueError (
259
+ f"Failed to load Hugging Face config for model_id='{ model_id_or_path } '.\
260
+ Ensure `model_id` is a valid Hugging Face repo or a local path that \
261
+ contains a valid `config.json` file. "
262
+ f"Original error: { repr (e )} "
263
+ ) from e
242
264
243
265
if model_architecture :
244
266
self ._model_architecture = model_architecture
0 commit comments