| Total Complexity | 0 |
| Total Lines | 60 |
| Duplicated Lines | 0 % |
| Changes | 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 = "paired_ct_lung" |
||
| 8 | |||
| 9 | # parser is used to simplify testing, by default it is not used |
||
| 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=False) |
||
| 27 | args = parser.parse_args() |
||
| 28 | |||
| 29 | print( |
||
| 30 | "\n\n\n\n\n" |
||
| 31 | "=========================================================\n" |
||
| 32 | "The prediction can also be launched using the following command.\n" |
||
| 33 | "deepreg_predict --gpu '' " |
||
| 34 | f"--config_path demos/{name}/{name}.yaml " |
||
| 35 | f"--ckpt_path demos/{name}/dataset/pretrained/ckpt-8000 " |
||
| 36 | f"--log_root demos/{name} " |
||
| 37 | "--log_dir logs_predict " |
||
| 38 | "--save_png --mode test\n" |
||
| 39 | "=========================================================\n" |
||
| 40 | "\n\n\n\n\n" |
||
| 41 | ) |
||
| 42 | |||
| 43 | log_root = f"demos/{name}" |
||
| 44 | log_dir = "logs_predict/" + datetime.now().strftime("%Y%m%d-%H%M%S") |
||
| 45 | ckpt_path = f"{log_root}/dataset/pretrained/ckpt-8000" |
||
| 46 | config_path = [f"{log_root}/{name}.yaml"] |
||
| 47 | if args.test: |
||
| 48 | config_path.append("config/test/demo_paired.yaml") |
||
| 49 | |||
| 50 | predict( |
||
| 51 | gpu="0", |
||
| 52 | gpu_allow_growth=True, |
||
| 53 | ckpt_path=ckpt_path, |
||
| 54 | mode="test", |
||
| 55 | batch_size=1, |
||
| 56 | log_root=log_root, |
||
| 57 | log_dir=log_dir, |
||
| 58 | sample_label="all", |
||
| 59 | config_path=config_path, |
||
| 60 | ) |
||
| 61 |