Completed
Push — main ( 0c57ec...f6b5bf )
by Yunguan
18s queued 13s
created

unpaired_mr_brain.demo_predict   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

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