-
Notifications
You must be signed in to change notification settings - Fork 10
/
make_data_split.py
59 lines (43 loc) · 1.52 KB
/
make_data_split.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
Make data splits for the dataloader.
Author: Bharat
Cite: LoopReg: Self-supervised Learning of Implicit Surface Correspondences, Pose and Shape for 3D Human Mesh Registration, NeurIPS' 20.
"""
import numpy as np
from glob import glob
from tqdm import tqdm
import pickle as pkl
import os
from os.path import split, join, exists
# Set the data path here. To use our dataloaders the directory structure should be as follows:
# -DATA_PATH
# --datasets-1
# ---subject-1
# ---subject-2
# --datasets-2
DATA_PATH = '/BS/bharat-2/static00/learnt_registration'
# add the folders you want to be the part of this dataset. Typically these would be the folders in side DATA_PATH
datasets = ['axyz', 'renderpeople', 'renderpeople_rigged', 'th_good_1', 'th_good_3', 'julian', 'treedy']
def function(datasets, split, save_path):
lis = []
for dataset in datasets:
for scan in tqdm(glob(join(DATA_PATH, dataset, '*'))):
lis.append(scan)
print(len(lis))
tr_lis, te_lis, count = [], [], 0
for dataset in datasets:
for scan in tqdm(glob(join(DATA_PATH, dataset, '*'))):
if count > split * len(lis):
tr_lis.append(scan)
else:
te_lis.append(scan)
count += 1
print('train', len(tr_lis), 'test', len(te_lis))
pkl.dump({'train': tr_lis, 'val': te_lis},
open(save_path, 'wb'))
def main():
SAVE_PATH = 'assets/data_split_01.pkl'
SPLIT = 0.1
function(datasets, SPLIT, SAVE_PATH)
if __name__ == "__main__":
main()