-
Notifications
You must be signed in to change notification settings - Fork 3
/
transfer.py
48 lines (41 loc) · 1.42 KB
/
transfer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import argparse
import os
import cv2
from utils.util import read_yaml_config
def main():
"""
USAGE
python3 transfer.py -c config_example.yaml
or
python3 transfer.py -c config_example.yaml --skip_cropping
"""
parser = argparse.ArgumentParser("Model inference")
parser.add_argument(
"-c",
"--config",
type=str,
default="./data/example/config.yaml",
help="Path to the config file.",
)
parser.add_argument("--skip_cropping", action="store_true")
args = parser.parse_args()
config = read_yaml_config(args.config)
H, W, _ = cv2.imread(config["INFERENCE_SETTING"]["TEST_X"]).shape
if not args.skip_cropping:
os.system(
f"python3 crop.py -i {config['INFERENCE_SETTING']['TEST_X']} "
f"-o {config['INFERENCE_SETTING']['TEST_DIR_X']} "
f"--patch_size {config['CROPPING_SETTING']['PATCH_SIZE']} "
f"--stride {config['CROPPING_SETTING']['PATCH_SIZE']} "
f"--thumbnail "
f"--thumbnail_output {config['INFERENCE_SETTING']['TEST_DIR_X']}"
)
print("Finish cropping and start inference")
os.system(f"python3 inference.py --config {args.config}")
print("Finish inference and start combining images")
os.system(
f"python3 combine.py --config {args.config} "
f"--resize_h {H} --resize_w {W}"
)
if __name__ == "__main__":
main()