MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / stack

Function stack

PATH/core/data/datasets/images/seg_data_tools/collate.py:10–24  ·  view source on GitHub ↗
(batch, data_key=None, return_dc=False)

Source from the content-addressed store, hash-verified

8
9
10def stack(batch, data_key=None, return_dc=False):
11 if isinstance(batch[0][data_key], DataContainer):
12 if batch[0][data_key].stack:
13 assert isinstance(batch[0][data_key].data, torch.Tensor)
14 samples = [sample[data_key].data for sample in batch]
15 return default_collate(samples)
16
17 elif not return_dc:
18 return [sample[data_key].data for sample in batch]
19
20 else:
21 return DataContainer([sample[data_key].data for sample in batch])
22
23 else:
24 return default_collate([sample[data_key] for sample in batch])
25
26
27def collate(batch, trans_dict):

Callers 1

collateFunction · 0.85

Calls 1

DataContainerClass · 0.85

Tested by

no test coverage detected