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

unpaired_ct_abdomen.demo_train   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 0
eloc 43
dl 0
loc 66
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_ct_abdomen"
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
    "--method",
15
    help="Training method, comb or unsup or weakly",
16
    type=str,
17
    required=True,
18
)
19
parser.add_argument(
20
    "--test",
21
    help="Execute the script for test purpose",
22
    dest="test",
23
    action="store_true",
24
)
25
parser.add_argument(
26
    "--no-test",
27
    help="Execute the script for non-test purpose",
28
    dest="test",
29
    action="store_false",
30
)
31
parser.set_defaults(test=True)
32
args = parser.parse_args()
33
method = args.method
34
35
assert method in [
36
    "comb",
37
    "unsup",
38
    "weakly",
39
], f"method should be comb or unsup or weakly, got {method}"
40
41
print(
42
    "\n\n\n\n\n"
43
    "=======================================================\n"
44
    "The training can also be launched using the following command.\n"
45
    "deepreg_train --gpu '0' "
46
    f"--config_path demos/{name}/{name}_{method}.yaml "
47
    f"--log_root demos/{name} "
48
    f"--log_dir logs_train/{method}\n"
49
    "=======================================================\n"
50
    "\n\n\n\n\n"
51
)
52
53
log_root = f"demos/{name}"
54
log_dir = f"logs_train/{method}/" + datetime.now().strftime("%Y%m%d-%H%M%S")
55
config_path = [f"demos/{name}/{name}_{method}.yaml"]
56
if args.test:
57
    config_path.append("config/test/demo_unpaired_grouped.yaml")
58
59
train(
60
    gpu="0",
61
    config_path=config_path,
62
    gpu_allow_growth=True,
63
    ckpt_path="",
64
    log_root=log_root,
65
    log_dir=log_dir,
66
)
67