-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
141 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
from .beit3d import BeitModel3D | ||
from .tokenizer import BertTokenizer | ||
from .vindlu_ret import VindLURetrieval | ||
from .vindlu_ret_mc import VindLURetrievalMC | ||
from .vindlu_vqa import VindLUVQA | ||
from .xbert import BertDecoder, BertModel | ||
from mmaction.utils.dependency import WITH_MULTIMODAL | ||
|
||
__all__ = [ | ||
'VindLUVQA', 'BertTokenizer', 'BertModel', 'BertDecoder', 'BeitModel3D', | ||
'VindLURetrievalMC', 'VindLURetrieval' | ||
] | ||
if WITH_MULTIMODAL: | ||
from .vindlu import * # noqa: F401,F403 | ||
|
||
else: | ||
from mmaction.registry import MODELS | ||
from mmaction.utils.dependency import register_multimodal_placeholder | ||
|
||
register_multimodal_placeholder( | ||
['VindLUVQA', 'VindLURetrievalMC', 'VindLURetrieval'], MODELS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
from .beit3d import BeitModel3D | ||
from .tokenizer import VindLUTokenizer | ||
from .vindlu_ret import VindLURetrieval | ||
from .vindlu_ret_mc import VindLURetrievalMC | ||
from .vindlu_vqa import VindLUVQA | ||
from .xbert import BertDecoder, BertModel | ||
|
||
__all__ = [ | ||
'VindLUVQA', 'VindLURetrievalMC', 'VindLURetrieval', 'VindLUTokenizer', | ||
'BeitModel3D', 'BertDecoder', 'BertModel' | ||
] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
import re | ||
from functools import wraps | ||
from inspect import isfunction | ||
|
||
from importlib_metadata import PackageNotFoundError, distribution | ||
from mmengine.utils import digit_version | ||
|
||
|
||
def satisfy_requirement(dep): | ||
pat = '(' + '|'.join(['>=', '==', '>']) + ')' | ||
parts = re.split(pat, dep, maxsplit=1) | ||
parts = [p.strip() for p in parts] | ||
package = parts[0] | ||
if len(parts) > 1: | ||
op, version = parts[1:] | ||
op = { | ||
'>=': '__ge__', | ||
'==': '__eq__', | ||
'>': '__gt__', | ||
'<': '__lt__', | ||
'<=': '__le__' | ||
}[op] | ||
else: | ||
op, version = None, None | ||
|
||
try: | ||
dist = distribution(package) | ||
if op is None or getattr(digit_version(dist.version), op)( | ||
digit_version(version)): | ||
return True | ||
except PackageNotFoundError: | ||
pass | ||
|
||
return False | ||
|
||
|
||
def require(dep, install=None): | ||
"""A wrapper of function for extra package requirements. | ||
Args: | ||
dep (str): The dependency package name, like ``transformers`` | ||
or ``transformers>=4.28.0``. | ||
install (str, optional): The installation command hint. Defaults | ||
to None, which means to use "pip install dep". | ||
""" | ||
|
||
def wrapper(fn): | ||
assert isfunction(fn) | ||
|
||
@wraps(fn) | ||
def ask_install(*args, **kwargs): | ||
name = fn.__qualname__.replace('.__init__', '') | ||
ins = install or f'pip install "{dep}"' | ||
raise ImportError( | ||
f'{name} requires {dep}, please install it by `{ins}`.') | ||
|
||
if satisfy_requirement(dep): | ||
fn._verify_require = getattr(fn, '_verify_require', lambda: None) | ||
return fn | ||
|
||
ask_install._verify_require = ask_install | ||
return ask_install | ||
|
||
return wrapper | ||
|
||
|
||
WITH_MULTIMODAL = all( | ||
satisfy_requirement(item) for item in ['transformers>=4.28.0']) | ||
|
||
|
||
def register_multimodal_placeholder(names, registry): | ||
for name in names: | ||
|
||
def ask_install(*args, **kwargs): | ||
raise ImportError( | ||
f'{name} requires extra multi-modal dependencies, please ' | ||
'install it by `pip install "mmaction2[multimodal]"` ' | ||
'or `pip install -e ".[multimodal]"`.') | ||
|
||
registry.register_module(name=name, module=ask_install) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
transformers>=4.28.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
|
||
FPS=2 | ||
SIZE=224 | ||
DATA_DIR="../../../data/msrvtt/videos" | ||
|