-
Notifications
You must be signed in to change notification settings - Fork 1
/
eval.py
53 lines (45 loc) · 1.64 KB
/
eval.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
import args
import data
import preprocessing as pre
import setup
from inc.config_snake.config import ConfigFile
from model import Model
def interface(config_file_path):
config_file = ConfigFile(config_file_path)
config = config_file.segmentation
assert config.training.validation_mode == "IID"
assert config.training.eval_mode == "hung"
evaluate(config)
def evaluate(config):
# SETUP
components = setup.setup(config)
image_info = components["image_info"]
heads_info = components["heads_info"]
output_files = components["output_files"]
state_folder = components["state_folder"]
image_folder = components["image_folder"]
net = components["net"]
model = Model.load(state_folder, net=net, use_best_net=True)
preprocessing = pre.SimplePreprocessing(
image_info=image_info,
prescale_all=config.preprocessor.prescale_all,
prescale_factor=config.preprocessor.prescale_factor,
)
preprocessor = pre.EvalImagePreprocessor(
image_info=image_info,
preprocessing=preprocessing,
output_files=output_files,
do_render=config.output.rendering.enabled,
render_limit=config.output.rendering.limit,
)
eval_dataset = data.EvalDataset(
eval_folder=image_folder,
preprocessor=preprocessor,
input_size=heads_info.input_size,
extensions=config.dataset.extensions,
)
eval_dataloader = data.EvalDataLoader(dataset=eval_dataset)
model.evaluate(output_files=output_files, loader=eval_dataloader)
if __name__ == "__main__":
arguments = args.Arguments()
interface(config_file_path=arguments.config_file_path)