MCPcopy Create free account
hub / github.com/MotrixLab/FineMoGen / TextMotionDataset

Class TextMotionDataset

mogen/datasets/text_motion_dataset.py:14–99  ·  view source on GitHub ↗

TextMotion dataset. Args: text_dir (str): Path to the directory containing the text files.

Source from the content-addressed store, hash-verified

12
13@DATASETS.register_module()
14class TextMotionDataset(BaseMotionDataset):
15 """TextMotion dataset.
16
17 Args:
18 text_dir (str): Path to the directory containing the text files.
19 """
20
21 def __init__(self,
22 data_prefix: str,
23 pipeline: list,
24 dataset_name: Optional[Union[str, None]] = None,
25 fixed_length: Optional[Union[int, None]] = None,
26 ann_file: Optional[Union[str, None]] = None,
27 motion_dir: Optional[Union[str, None]] = None,
28 text_dir: Optional[Union[str, None]] = None,
29 token_dir: Optional[Union[str, None]] = None,
30 clip_feat_dir: Optional[Union[str, None]] = None,
31 eval_cfg: Optional[Union[dict, None]] = None,
32 test_mode: Optional[bool] = False,
33 siamese_mode: Optional[bool] = False,
34 tcomb_mode: Optional[bool] = False):
35 self.text_dir = os.path.join(data_prefix, 'datasets', dataset_name,
36 text_dir)
37 if token_dir is not None:
38 self.token_dir = os.path.join(data_prefix, 'datasets',
39 dataset_name, token_dir)
40 else:
41 self.token_dir = None
42 if clip_feat_dir is not None:
43 self.clip_feat_dir = os.path.join(data_prefix, 'datasets',
44 dataset_name, clip_feat_dir)
45 else:
46 self.clip_feat_dir = None
47 self.siamese_mode = siamese_mode
48 self.tcomb_mode = tcomb_mode
49 super(TextMotionDataset, self).__init__(data_prefix=data_prefix,
50 pipeline=pipeline,
51 dataset_name=dataset_name,
52 fixed_length=fixed_length,
53 ann_file=ann_file,
54 motion_dir=motion_dir,
55 eval_cfg=eval_cfg,
56 test_mode=test_mode)
57
58 def load_anno(self, name):
59 results = {}
60 if self.siamese_mode:
61 motion_path = os.path.join(self.motion_dir, name + '.npz')
62 motion_data = np.load(motion_path)
63 results['motion1'] = motion_data['motion1']
64 results['motion2'] = motion_data['motion2']
65 assert results['motion1'].shape == results['motion2'].shape
66 else:
67 motion_path = os.path.join(self.motion_dir, name + '.npy')
68 motion_data = np.load(motion_path)
69 results['motion'] = motion_data
70 text_path = os.path.join(self.text_dir, name + '.txt')
71 text_data = []

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected