-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcrop_pipeline.py
executable file
·40 lines (36 loc) · 1.37 KB
/
crop_pipeline.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
# Author: Kaminyou (https://github.com/Kaminyou)
import argparse
import os
from utils.util import read_yaml_config
if __name__ == "__main__":
parser = argparse.ArgumentParser("Model inference")
parser.add_argument(
"-c",
"--config",
type=str,
default="./data/example/config.yaml",
help="Path to the config file.",
)
args = parser.parse_args()
config = read_yaml_config(args.config)["CROPPING_SETTING"]
# Prepare the training set
for train_x, train_y in zip(config["TRAIN_X"], config["TRAIN_Y"]):
os.system(
f"python3 crop.py -i {train_x} -o {config['TRAIN_DIR_X']} "
f"--patch_size {config['PATCH_SIZE']} --stride {config['STRIDE']}"
)
os.system(
f"python3 crop.py -i {train_y} -o {config['TRAIN_DIR_Y']} "
f"--patch_size {config['PATCH_SIZE']} --stride {config['STRIDE']}"
)
# Prepare the testing set
for test_x in config["TEST_X"]:
basename = os.path.basename(test_x)
filename = os.path.splitext(basename)[0]
output_path = os.path.join(config['TEST_DIR_X'], filename)
os.system(
f"python3 crop.py -i {test_x} -o {output_path} "
f"--thumbnail --thumbnail_output {output_path} "
f"--patch_size {config['PATCH_SIZE']} "
f"--stride {config['PATCH_SIZE']}"
)