-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_all.py
95 lines (71 loc) · 2.47 KB
/
run_all.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
import os
import sys
import subprocess
import argparse
import kitti
def parse_arguments():
parser = argparse.ArgumentParser(
description="Run projection.py, segmentation.py, scale_field.py, and normal_vectors.py \
scripts on the entire dataset."
)
parser.add_argument("--prompt", help="Segmentation prompt")
parser.add_argument(
"--interpolation", help="Interpolation method, linear, nearest, cubic, None"
)
parser.add_argument("--debug", action="store_true", help="Enable debug mode")
return parser.parse_args()
def run_script(script_name, args):
command = [sys.executable, script_name] + args
print(f"Running: {script_name} with {args}")
try:
process = subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
bufsize=1,
universal_newlines=True,
)
for line in process.stdout: # type: ignore
print(line, end="")
process.wait()
if process.returncode != 0:
print(f"Error: {script_name} exited with status {process.returncode}")
except Exception as e:
print(f"Error running {script_name}: {e}")
def main():
args = parse_arguments()
all_date_drive = kitti.all_date_drive()
cam = 2
prompt = args.prompt
interpolation = args.interpolation
debug = args.debug
num = len(all_date_drive)
print(f"Main folder: {kitti.DATASET_PATH}")
print(f"Number of date-drives: {num}")
for d in all_date_drive:
date = d['date']
drive = d['drive']
print(f"Current date-drive: {date} - {drive}: ")
# projection
args = [date, str(drive), str(cam)]
if debug:
args.append('--debug')
run_script("projection.py", args)
# segmentation
args = [date, str(drive), str(cam), '--prompt', prompt]
if debug:
args.append('--debug')
run_script("segmentation.py", args)
# scale_field
args = [date, str(drive), str(cam), '--prompt', prompt, '--interpolation', interpolation]
if debug:
args.append('--debug')
run_script("scale_field.py", args)
# normal_vectors
args = [date, str(drive), str(cam), '--prompt', prompt, '--interpolation', interpolation]
if debug:
args.append('--debug')
run_script("normal_vectors.py", args)
if __name__ == "__main__":
main()