-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_generator.py
More file actions
48 lines (39 loc) · 1.22 KB
/
data_generator.py
File metadata and controls
48 lines (39 loc) · 1.22 KB
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
from utils.data import get_imageset_in_memory, clean_and_stash_numpys
import os
mask_opt = 'masked'
color_opt = 'full'
balance_opt = 'unbalanced'
cwd = os.getcwd()
parent_dir = 'model_data'
opt_str = "_".join([mask_opt, color_opt, balance_opt])
train_dir = "_".join(['train', 'numpy', opt_str])
train_path = os.path.join(cwd, parent_dir, train_dir)
test_dir = "_".join(['test', 'numpy', opt_str])
test_path = os.path.join(cwd, parent_dir, test_dir)
image_set_dir = os.path.join(cwd, 'data')
test_img_name = '2015-04-029_20X_C57Bl6_E16.5_LMM.14.24.4.46_SOX9_SFTPC_ACTA2_001.tif'
if not os.path.exists(train_path):
os.makedirs(train_path)
if not os.path.exists(test_path):
os.makedirs(test_path)
if mask_opt == 'masked':
is_masked = True
else:
is_masked = False
if balance_opt == 'balanced':
is_balanced = True
else:
is_balanced = False
if color_opt == 'pseudo':
is_pseudo = True
else:
is_pseudo = False
x, extra_x, y, test_x, test_extra_x, test_y = get_imageset_in_memory(
image_set_dir,
test_img_name,
balance_train=is_balanced,
masked=is_masked,
pseudo_color=is_pseudo
)
clean_and_stash_numpys(x, extra_x, y, train_path)
clean_and_stash_numpys(test_x, test_extra_x, test_y, test_path)