Error in load_model_ensemble_and_task_from_hf_hub()

#1
by qqq22558 - opened

Hi all,

When I run the code, it first download model and config file successfully, but get error after downloading.

models, cfg, task = load_model_ensemble_and_task_from_hf_hub(
"facebook/xm_transformer_s2ut_hk-en",
arg_overrides={"config_yaml": "config.yaml", "task": "speech_to_text"},
cache_dir='cache_dir_unity_hken',
)

Error message:

Fetching 5 files: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 5/5 [00:00<00:00, 42111.49it/s]

TypeError Traceback (most recent call last)
File ~/anaconda3/envs/hokkien/lib/python3.8/site-packages/omegaconf/dictconfig.py:303, in DictConfig.getattr(self, key)
301 raise ConfigAttributeError()
--> 303 return self._get_impl(key=key, default_value=DEFAULT_VALUE_MARKER)
304 except Exception as e:

File ~/anaconda3/envs/hokkien/lib/python3.8/site-packages/omegaconf/dictconfig.py:361, in DictConfig._get_impl(self, key, default_value)
360 try:
--> 361 node = self._get_node(key=key)
362 except ConfigAttributeError:

File ~/anaconda3/envs/hokkien/lib/python3.8/site-packages/omegaconf/dictconfig.py:375, in DictConfig._get_node(self, key, validate_access)
374 try:
--> 375 key = self._validate_and_normalize_key(key)
376 except KeyValidationError:

File ~/anaconda3/envs/hokkien/lib/python3.8/site-packages/omegaconf/dictconfig.py:222, in DictConfig._validate_and_normalize_key(self, key)
221 def _validate_and_normalize_key(self, key: Any) -> Union[str, Enum]:
--> 222 return self._s_validate_and_normalize_key(self._metadata.key_type, key)

File ~/anaconda3/envs/hokkien/lib/python3.8/site-packages/omegaconf/dictconfig.py:241, in DictConfig._s_validate_and_normalize_key(self, key_type, key)
240 return key
--> 241 elif issubclass(key_type, Enum):
242 try:

TypeError: issubclass() arg 1 must be a class

During handling of the above exception, another exception occurred:

TypeError Traceback (most recent call last)
Cell In[5], line 1
----> 1 models, cfg, task = load_model_ensemble_and_task_from_hf_hub(
2 "facebook/xm_transformer_s2ut_hk-en",
3 arg_overrides={"config_yaml": "config.yaml", "task": "speech_to_text"},
4 cache_dir='cache_dir_unity_hken',
5 )
6 #model = models[0].cpu()
7 #cfg["task"].cpu = True
8 generator = task.build_generator([model], cfg)

File /data3/backup/speech/xm_transformer_unity_hk-en/fairseq/fairseq/checkpoint_utils.py:532, in load_model_ensemble_and_task_from_hf_hub(model_id, cache_dir, arg_overrides, *kwargs)
530 _arg_overrides = arg_overrides or {}
531 _arg_overrides["data"] = cache_dir
--> 532 return load_model_ensemble_and_task(
533 [p.as_posix() for p in Path(cache_dir).glob("
.pt")],
534 arg_overrides=_arg_overrides,
535 )

File /data3/backup/speech/xm_transformer_unity_hk-en/fairseq/fairseq/checkpoint_utils.py:432, in load_model_ensemble_and_task(filenames, arg_overrides, task, strict, suffix, num_shards, state)
430 raise IOError("Model file not found: {}".format(filename))
431 if state is None:
--> 432 state = load_checkpoint_to_cpu(filename, arg_overrides)
433 if "args" in state and state["args"] is not None:
434 cfg = convert_namespace_to_omegaconf(state["args"])

File /data3/backup/speech/xm_transformer_unity_hk-en/fairseq/fairseq/checkpoint_utils.py:350, in load_checkpoint_to_cpu(path, arg_overrides, load_on_all_ranks)
347 if arg_overrides is not None:
348 overwrite_args_by_name(state["cfg"], arg_overrides)
--> 350 state = _upgrade_state_dict(state)
351 return state

File /data3/backup/speech/xm_transformer_unity_hk-en/fairseq/fairseq/checkpoint_utils.py:715, in _upgrade_state_dict(state)
706 if "generation" in cfg and isinstance(cfg.generation.print_alignment, bool):
707 cfg.generation.print_alignment = (
708 "hard" if cfg.generation.print_alignment else None
709 )
710 if (
711 "model" in cfg
712 and "w2v_args" in cfg.model
713 and cfg.model.w2v_args is not None
714 and (
--> 715 hasattr(cfg.model.w2v_args, "task") or "task" in cfg.model.w2v_args
716 )
717 and hasattr(cfg.model.w2v_args.task, "eval_wer_config")
718 and cfg.model.w2v_args.task.eval_wer_config is not None
719 and isinstance(
720 cfg.model.w2v_args.task.eval_wer_config.print_alignment, bool
721 )
722 ):
723 cfg.model.w2v_args.task.eval_wer_config.print_alignment = "hard"
725 return state

File ~/anaconda3/envs/hokkien/lib/python3.8/site-packages/omegaconf/dictconfig.py:305, in DictConfig.getattr(self, key)
303 return self._get_impl(key=key, default_value=DEFAULT_VALUE_MARKER)
304 except Exception as e:
--> 305 self._format_and_raise(key=key, value=None, cause=e)

File ~/anaconda3/envs/hokkien/lib/python3.8/site-packages/omegaconf/base.py:95, in Node._format_and_raise(self, key, value, cause, type_override)
92 def _format_and_raise(
93 self, key: Any, value: Any, cause: Exception, type_override: Any = None
94 ) -> None:
---> 95 format_and_raise(
96 node=self,
97 key=key,
98 value=value,
99 msg=str(cause),
100 cause=cause,
101 type_override=type_override,
102 )
103 assert False

File ~/anaconda3/envs/hokkien/lib/python3.8/site-packages/omegaconf/_utils.py:644, in format_and_raise(node, key, value, msg, cause, type_override)
642 else:
643 if key is not None and not OmegaConf.is_none(node):
--> 644 child_node = node._get_node(key, validate_access=False)
646 full_key = node._get_full_key(key=key)
648 object_type = OmegaConf.get_type(node)

File ~/anaconda3/envs/hokkien/lib/python3.8/site-packages/omegaconf/dictconfig.py:375, in DictConfig._get_node(self, key, validate_access)
371 def _get_node(
372 self, key: Union[str, Enum], validate_access: bool = True
373 ) -> Optional[Node]:
374 try:
--> 375 key = self._validate_and_normalize_key(key)
376 except KeyValidationError:
377 if validate_access:

File ~/anaconda3/envs/hokkien/lib/python3.8/site-packages/omegaconf/dictconfig.py:222, in DictConfig._validate_and_normalize_key(self, key)
221 def _validate_and_normalize_key(self, key: Any) -> Union[str, Enum]:
--> 222 return self._s_validate_and_normalize_key(self._metadata.key_type, key)

File ~/anaconda3/envs/hokkien/lib/python3.8/site-packages/omegaconf/dictconfig.py:241, in DictConfig._s_validate_and_normalize_key(self, key_type, key)
236 raise KeyValidationError(
237 f"Key $KEY ($KEY_TYPE) is incompatible with ({key_type.name})"
238 )
240 return key
--> 241 elif issubclass(key_type, Enum):
242 try:
243 ret = EnumNode.validate_and_convert_to_enum(key_type, key)

TypeError: issubclass() arg 1 must be a class

I can't figure out what's wrong with the error message.
Any one can help?
Thanks!!

i have the same error

Sign up or log in to comment