-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevaluate.py
99 lines (86 loc) · 3.55 KB
/
evaluate.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
#
# Copyright (C) 2023, Inria
# GRAPHDECO research group, https://team.inria.fr/graphdeco
# All rights reserved.
#
# This software is free for non-commercial, research and evaluation use
# under the terms of the LICENSE.md file.
#
# For inquiries contact [email protected]
#
import os
from argparse import ArgumentParser
from time import time
phantom = ["c3v4", "d4v2", "t1v1"]
# phantom = []
simulation = ["cecum", "rectum", "sigmoid"]
# simulation = []
in_vivo = ["invivo56", "invivo31", "invivo57"]
# in_vivo = []
in_vivo_2 = ["020", "027", "051", "064", "039", "055", "063", "035", "067"]
#in_vivo_2 = []
parser = ArgumentParser(description="Full evaluation script parameters")
parser.add_argument("--data_path", required=True)
parser.add_argument("--skip_training", action="store_true")
parser.add_argument("--skip_rendering", action="store_true")
parser.add_argument("--skip_metrics", action="store_true")
parser.add_argument("--output_path", default="./eval")
args, _ = parser.parse_known_args()
all_scenes = []
if phantom:
all_scenes.extend(phantom)
if simulation:
all_scenes.extend(simulation)
if in_vivo:
all_scenes.extend(in_vivo)
if in_vivo_2:
all_scenes.extend(in_vivo_2)
all_times = []
if not args.skip_training:
common_args = " --quiet --eval --test_iterations -1 --save_iterations 7000"
if phantom:
for scene in phantom:
start = time()
source = args.data_path + "/01-phantom/" + scene
os.system("python train.py -s " + source + " --iterations 7000 --res 4 -m " + args.output_path + "/" + scene + common_args)
end = time()
print("Training time for " + scene + ": " + str(end - start) + " seconds")
all_times.append(end - start)
if simulation:
for scene in simulation:
start = time()
source = args.data_path + "/02-simulation/" + scene
os.system("python train.py -s " + source + " --iterations 7000 -m " + args.output_path + "/" + scene + common_args)
end = time()
print("Training time for " + scene + ": " + str(end - start) + " seconds")
all_times.append(end - start)
if in_vivo or in_vivo_2:
for scene in in_vivo + in_vivo_2:
start = time()
source = args.data_path + "/00-in-vivo/" + scene
os.system("python train.py -s " + source + " --iterations 7000 -m " + args.output_path + "/" + scene + common_args)
end = time()
print("Training time for " + scene + ": " + str(end - start) + " seconds")
all_times.append(end - start)
if not args.skip_rendering:
all_sources = []
if phantom:
for scene in phantom:
all_sources.append(args.data_path + "/01-phantom/" + scene)
if simulation:
for scene in simulation:
all_sources.append(args.data_path + "/02-simulation/" + scene)
if in_vivo or in_vivo_2:
for scene in in_vivo + in_vivo_2:
all_sources.append(args.data_path + "/00-in-vivo/" + scene)
common_args = " --quiet --eval"
for scene, source in zip(all_scenes, all_sources):
os.system("python render.py --iteration 7000 -s " + source + " -m " + args.output_path + "/" + scene + common_args)
if not args.skip_metrics:
scenes_string = ""
for scene in all_scenes:
scenes_string += "\"" + args.output_path + "/" + scene + "\" "
if all_times:
os.system("python metrics.py -m " + scenes_string + " -t " + " ".join([str(t) for t in all_times]))
else:
os.system("python metrics.py -m " + scenes_string)