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

grouped_mask_prostate_longitudinal.demo_train   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

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