grouped_mr_heart.demo_predict   A
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 0
eloc 35
dl 0
loc 58
rs 10
c 0
b 0
f 0
1
import argparse
2
from datetime import datetime
3
4
from deepreg.predict import predict
5
6
name = "grouped_mr_heart"
7
8
# parser is used to simplify testing, by default it is not used
9
# please run the script with --full flag to ensure non-testing mode
10
# for instance:
11
# python script.py --full
12
parser = argparse.ArgumentParser()
13
parser.add_argument(
14
    "--test",
15
    help="Execute the script with reduced image size for test purpose.",
16
    dest="test",
17
    action="store_true",
18
)
19
parser.add_argument(
20
    "--full",
21
    help="Execute the script with full configuration.",
22
    dest="test",
23
    action="store_false",
24
)
25
parser.set_defaults(test=False)
26
args = parser.parse_args()
27
28
print(
29
    "\n\n\n\n\n"
30
    "=========================================================\n"
31
    "The prediction can also be launched using the following command.\n"
32
    "deepreg_predict --gpu '' "
33
    f"--config_path demos/{name}/{name}.yaml "
34
    f"--ckpt_path demos/{name}/dataset/pretrained/ckpt-4000 "
35
    f"--log_dir demos/{name} "
36
    "--exp_name logs_predict "
37
    "--save_png --split test\n"
38
    "=========================================================\n"
39
    "\n\n\n\n\n"
40
)
41
42
log_dir = f"demos/{name}"
43
exp_name = "logs_predict/" + datetime.now().strftime("%Y%m%d-%H%M%S")
44
ckpt_path = f"{log_dir}/dataset/pretrained/ckpt-4000"
45
config_path = [f"{log_dir}/{name}.yaml"]
46
if args.test:
47
    config_path.append("config/test/demo_unpaired_grouped.yaml")
48
49
predict(
50
    gpu="0",
51
    gpu_allow_growth=True,
52
    ckpt_path=ckpt_path,
53
    split="test",
54
    batch_size=1,
55
    log_dir=log_dir,
56
    exp_name=exp_name,
57
    config_path=config_path,
58
)
59