@@ -35,7 +35,7 @@ def map_fn(file:str, save_defects=False):
35
35
for shape in annotations ['shapes' ]:
36
36
# use only one label name
37
37
if shape ['label' ].upper () == 'VERTICAL DEFECT' :
38
- shape ['label' ] = 'VERTICAL'
38
+ shape ['label' ] = 'VERTICAL'
39
39
if shape ['label' ].upper () == 'SPATTING' :
40
40
shape ['label' ] = 'SPATTERING'
41
41
@@ -57,7 +57,7 @@ def make_dataset(tuples):
57
57
return tf .data .Dataset .from_tensor_slices ((x , y ))
58
58
59
59
class AMDdataset ():
60
- ''' Additive Manufactoring dataset class'''
60
+ """ Additive Manufactoring dataset class"""
61
61
62
62
def __init__ (self , path , image_shape = (1280 , 1024 , 3 )):
63
63
self .path = path
@@ -70,7 +70,6 @@ def build(self):
70
70
if len (folders ) != len (REQUIRED_FOLDERS ):
71
71
raise FileNotFoundError (f'Directory { self .path } does not contain correct folders. It must contains { REQUIRED_FOLDERS } ' )
72
72
73
- # TODO split the dataset and load it into 3 tf.dataset: self.train, self.val, self.test
74
73
train = []
75
74
test = []
76
75
val = []
@@ -80,19 +79,16 @@ def build(self):
80
79
files = np .array (glob (os .path .join (self .path , f ,'*.jpg' )))
81
80
if len (files ) == 0 :
82
81
continue
83
- n = len (files ) // 3
82
+ n = len (files ) // 9
84
83
idx = np .random .permutation (np .arange (len (files )))
85
84
86
- test .extend (files [idx [:n ]])
87
- val .extend (files [idx [n : n * 2 ]])
88
- train .extend (files [idx [n * 2 :]])
85
+ test .extend (files [idx [:3 * n ]]) # 3/9
86
+ val .extend (files [idx [3 * n : 5 * n ]]) # 2/9
87
+ train .extend (files [idx [5 * n :]]) # 4/9
89
88
90
89
train = [map_fn (x , True ) for x in train ]
91
- test = [map_fn (x ) for x in test ]
92
- val = [map_fn (x , True ) for x in val ]
93
-
94
- # img, mask = train[0]
95
- # apply_mask_on_image(img, mask, "../visualize")
90
+ test = [map_fn (x ) for x in test ]
91
+ val = [map_fn (x , True ) for x in val ]
96
92
97
93
# build the datasets
98
94
self .train = make_dataset (train )
0 commit comments