Shortcuts

Source code for mmaction.datasets.transforms.text_transforms

# Copyright (c) OpenMMLab. All rights reserved.
from typing import Dict

from mmcv.transforms import BaseTransform

from mmaction.registry import TRANSFORMS


[docs]@TRANSFORMS.register_module() class CLIPTokenize(BaseTransform): """Tokenize text and convert to tensor."""
[docs] def transform(self, results: Dict) -> Dict: """The transform function of :class:`CLIPTokenize`. Args: results (dict): The result dict. Returns: dict: The result dict. """ try: import clip except ImportError: raise ImportError('Please run `pip install ' 'git+https://github.com/openai/CLIP.git` ' 'to install clip first. ') text = results['text'] text_tokenized = clip.tokenize(text)[0] results['text'] = text_tokenized return results
Read the Docs v: latest
Versions
latest
stable
1.x
0.x
dev-1.x
Downloads
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.