facebookresearch / fairseq

Facebook AI Research Sequence-to-Sequence Toolkit written in Python.
MIT License
30.59k stars 6.41k forks source link

Has anyone got the MMPT example to work? #5538

Open qingy1337 opened 2 months ago

qingy1337 commented 2 months ago

🐛 Bug

I am running into so many dependency errors when trying to use VideoCLIP model. If anyone has gotten it to work please share your details on which package versions you have installed, etc.

By the way, I'm trying to get the model to compare if a video and text match and get a score from that.

I am currently stuck with this error while running the example code:

---------------------------------------------------------------------------
ConfigAttributeError                      Traceback (most recent call last)
Cell In[1], line 6
      1 import torch
      3 from mmpt.models import MMPTModel
----> 6 model, tokenizer, aligner = MMPTModel.from_pretrained(
      7     "projects/retri/videoclip/how2.yaml")
      9 model.eval()
     12 # B, T, FPS, H, W, C (VideoCLIP is trained on 30 fps of s3d)

File ~/PycharmProjects/fairseq/examples/MMPT/mmpt/models/mmfusion.py:39, in MMPTModel.from_pretrained(cls, config, checkpoint)
     37 from ..utils import recursive_config
     38 from ..tasks import Task
---> 39 config = recursive_config(config)
     40 mmtask = Task.config_task(config)
     41 checkpoint_path = os.path.join(config.eval.save_path, checkpoint)

File ~/PycharmProjects/fairseq/examples/MMPT/mmpt/utils/load_config.py:58, in recursive_config(config_path)
     56 """allows for stacking of configs in any depth."""
     57 config = OmegaConf.load(config_path)
---> 58 if config.includes is not None:
     59     includes = config.includes
     60     config.pop("includes")

File /opt/anaconda3/envs/test_env_3_9/lib/python3.9/site-packages/omegaconf/dictconfig.py:355, in DictConfig.__getattr__(self, key)
    351     return self._get_impl(
    352         key=key, default_value=_DEFAULT_MARKER_, validate_key=False
    353     )
    354 except ConfigKeyError as e:
--> 355     self._format_and_raise(
    356         key=key, value=None, cause=e, type_override=ConfigAttributeError
    357     )
    358 except Exception as e:
    359     self._format_and_raise(key=key, value=None, cause=e)

File /opt/anaconda3/envs/test_env_3_9/lib/python3.9/site-packages/omegaconf/base.py:231, in Node._format_and_raise(self, key, value, cause, msg, type_override)
    223 def _format_and_raise(
    224     self,
    225     key: Any,
   (...)
    229     type_override: Any = None,
    230 ) -> None:
--> 231     format_and_raise(
    232         node=self,
    233         key=key,
    234         value=value,
    235         msg=str(cause) if msg is None else msg,
    236         cause=cause,
    237         type_override=type_override,
    238     )
    239     assert False

File /opt/anaconda3/envs/test_env_3_9/lib/python3.9/site-packages/omegaconf/_utils.py:899, in format_and_raise(node, key, value, msg, cause, type_override)
    896     ex.ref_type = ref_type
    897     ex.ref_type_str = ref_type_str
--> 899 _raise(ex, cause)

File /opt/anaconda3/envs/test_env_3_9/lib/python3.9/site-packages/omegaconf/_utils.py:797, in _raise(ex, cause)
    795 else:
    796     ex.__cause__ = None
--> 797 raise ex.with_traceback(sys.exc_info()[2])

File /opt/anaconda3/envs/test_env_3_9/lib/python3.9/site-packages/omegaconf/dictconfig.py:351, in DictConfig.__getattr__(self, key)
    348     raise AttributeError()
    350 try:
--> 351     return self._get_impl(
    352         key=key, default_value=_DEFAULT_MARKER_, validate_key=False
    353     )
    354 except ConfigKeyError as e:
    355     self._format_and_raise(
    356         key=key, value=None, cause=e, type_override=ConfigAttributeError
    357     )

File /opt/anaconda3/envs/test_env_3_9/lib/python3.9/site-packages/omegaconf/dictconfig.py:442, in DictConfig._get_impl(self, key, default_value, validate_key)
    438 def _get_impl(
    439     self, key: DictKeyType, default_value: Any, validate_key: bool = True
    440 ) -> Any:
    441     try:
--> 442         node = self._get_child(
    443             key=key, throw_on_missing_key=True, validate_key=validate_key
    444         )
    445     except (ConfigAttributeError, ConfigKeyError):
    446         if default_value is not _DEFAULT_MARKER_:

File /opt/anaconda3/envs/test_env_3_9/lib/python3.9/site-packages/omegaconf/basecontainer.py:73, in BaseContainer._get_child(self, key, validate_access, validate_key, throw_on_missing_value, throw_on_missing_key)
     64 def _get_child(
     65     self,
     66     key: Any,
   (...)
     70     throw_on_missing_key: bool = False,
     71 ) -> Union[Optional[Node], List[Optional[Node]]]:
     72     """Like _get_node, passing through to the nearest concrete Node."""
---> 73     child = self._get_node(
     74         key=key,
     75         validate_access=validate_access,
     76         validate_key=validate_key,
     77         throw_on_missing_value=throw_on_missing_value,
     78         throw_on_missing_key=throw_on_missing_key,
     79     )
     80     if isinstance(child, UnionNode) and not _is_special(child):
     81         value = child._value()

File /opt/anaconda3/envs/test_env_3_9/lib/python3.9/site-packages/omegaconf/dictconfig.py:480, in DictConfig._get_node(self, key, validate_access, validate_key, throw_on_missing_value, throw_on_missing_key)
    478 if value is None:
    479     if throw_on_missing_key:
--> 480         raise ConfigKeyError(f"Missing key {key!s}")
    481 elif throw_on_missing_value and value._is_missing():
    482     raise MissingMandatoryValue("Missing mandatory value: $KEY")

ConfigAttributeError: Missing key includes
    full_key: includes
    object_type=dict
toqaalaa20 commented 1 month ago

You can install omegaconf==2.0.0 it solved this issue for me