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

demo_train   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

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