-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare_data.py
104 lines (92 loc) · 2.69 KB
/
prepare_data.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python3
# Copyright 2004-present Facebook. All Rights Reserved.
# Copyright 2023-present Edoardo Mello Rella, Ajad Chhatkuli, Ender Konukoglu & Luc Van Gool
import argparse
import json
import logging
import os
import subprocess
import implicit_vf
import implicit_vf.workspace as ws
from sampling_loader.vf_sampling import VFSampling
from torch.utils.data import DataLoader
if __name__ == "__main__":
arg_parser = argparse.ArgumentParser(
formatter_class=argparse.RawTextHelpFormatter,
description="Prepare dataset to use for training, inference, and evaluation from a set of meshes",
)
arg_parser.add_argument(
"--data_dir",
"-d",
dest="data_dir",
required=True,
help="The directory which holds all preprocessed data.",
)
arg_parser.add_argument(
"--source",
"-s",
dest="source_dir",
required=True,
help="The directory which holds the data to preprocess and append.",
)
arg_parser.add_argument(
"--name",
"-n",
dest="source_name",
default=None,
help="The name to use for the data source. If unspecified, it defaults to the "
+ "directory name.",
)
arg_parser.add_argument(
"--split",
dest="split_filename",
required=True,
help="A split filename defining the shapes to be processed.",
)
arg_parser.add_argument(
"--skip",
dest="skip",
default=False,
action="store_true",
help="If set, previously-processed shapes will be skipped",
)
arg_parser.add_argument(
"--threads",
dest="num_threads",
default=8,
help="The number of threads to use to process the data.",
)
arg_parser.add_argument(
"--test",
"-t",
dest="test_sampling",
default=False,
action="store_true",
help="If set, the script will produce VF samplies for testing."
+ "Otherwise for training",
)
implicit_vf.add_common_args(arg_parser)
args = arg_parser.parse_args()
implicit_vf.configure_logging(args)
subdir = ws.vf_samples_subdir
extension = ".npz"
executable = VFSampling(
args=args,
subdir=subdir,
extension=extension,
test_sampling=args.test_sampling,
)
sampling_loader = DataLoader(
executable,
batch_size=1,
shuffle=False,
pin_memory=False,
drop_last=False,
num_workers=8,
)
for el, file_name in enumerate(sampling_loader):
print(
"Processed file {} at position {} of {}".format(
file_name, el, len(executable)
)
)