-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_patchify.py
62 lines (47 loc) · 1.47 KB
/
run_patchify.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# @author: Ishman Mann
# @date: 05/12/2022
#
# @description:
# Save patchified dataset images before model training
#
# @resources:
#
#
# @notes:
#
#
# @ToDo:
# Consider dynamic patchifying
#
##############################################
from utils import patchify_images
from dotenv import load_dotenv
import os
load_dotenv('.env')
# Globals and hyperparameters
PATCH_WIDTH = int(os.environ["PATCH_WIDTH"])
PATCH_HEIGHT = int(os.environ["PATCH_HEIGHT"])
PATCH_SIZE = (PATCH_HEIGHT, PATCH_WIDTH)
STEP = 500
IMAGE_SAVE_TYPE = os.environ["IMAGE_SAVE_TYPE"]
MASK_SAVE_TYPE = os.environ["MASK_SAVE_TYPE"]
PATCHIFY_QUEUE = [
{"name":"TRAIN_IMAGES", "save_type":IMAGE_SAVE_TYPE},
{"name":"TRAIN_MASKS", "save_type":MASK_SAVE_TYPE},
{"name":"TEST_IMAGES", "save_type":IMAGE_SAVE_TYPE},
{"name":"TEST_MASKS", "save_type":MASK_SAVE_TYPE},
{"name":"VALIDATION_IMAGES", "save_type":IMAGE_SAVE_TYPE},
{"name":"VALIDATION_MASKS", "save_type":MASK_SAVE_TYPE}
]
if __name__ == "__main__":
for image_set in PATCHIFY_QUEUE:
print("Patchifying " + image_set["name"])
images_dir = os.environ[image_set["name"] + "_DIR"]
patches_dir = os.environ["PATCHIFIED_" + image_set["name"] + "_DIR"]
patchify_images(
images_dir=images_dir,
patches_dir=patches_dir,
save_type=image_set["save_type"],
patch_size=PATCH_SIZE,
step=STEP
)