MCPcopy Create free account
hub / github.com/Audio-AGI/AudioSep / get_data_module

Function get_data_module

train.py:87–136  ·  view source on GitHub ↗

r"""Create data_module. Mini-batch data can be obtained by: code-block:: python data_module.setup() for batch_data_dict in data_module.train_dataloader(): print(batch_data_dict.keys()) break Args: workspace: str config_yaml: str

(
    config_yaml: str,
    num_workers: int,
    batch_size: int,
)

Source from the content-addressed store, hash-verified

85
86
87def get_data_module(
88 config_yaml: str,
89 num_workers: int,
90 batch_size: int,
91) -> DataModule:
92 r"""Create data_module. Mini-batch data can be obtained by:
93
94 code-block:: python
95
96 data_module.setup()
97
98 for batch_data_dict in data_module.train_dataloader():
99 print(batch_data_dict.keys())
100 break
101
102 Args:
103 workspace: str
104 config_yaml: str
105 num_workers: int, e.g., 0 for non-parallel and 8 for using cpu cores
106 for preparing data in parallel
107 distributed: bool
108
109 Returns:
110 data_module: DataModule
111 """
112
113 # read configurations
114 configs = parse_yaml(config_yaml)
115 sampling_rate = configs['data']['sampling_rate']
116 segment_seconds = configs['data']['segment_seconds']
117
118 # audio-text datasets
119 datafiles = configs['data']['datafiles']
120
121 # dataset
122 dataset = AudioTextDataset(
123 datafiles=datafiles,
124 sampling_rate=sampling_rate,
125 max_clip_len=segment_seconds,
126 )
127
128
129 # data module
130 data_module = DataModule(
131 train_dataset=dataset,
132 num_workers=num_workers,
133 batch_size=batch_size
134 )
135
136 return data_module
137
138
139def train(args) -> NoReturn:

Callers 1

trainFunction · 0.85

Calls 3

parse_yamlFunction · 0.90
AudioTextDatasetClass · 0.85
DataModuleClass · 0.85

Tested by

no test coverage detected