Skip to content

Commit 75e165e

Browse files
authored
Dev loader refactor (#111)
* refactored loaders, fixed weighed loss calculation * updated config * reverted resnet 152 to 32 filters with no dropout * removed print * back to 1000 valid size * back to old batch size * back other params * config
1 parent 79cef73 commit 75e165e

File tree

6 files changed

+175
-326
lines changed

6 files changed

+175
-326
lines changed

augmentation.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
fast_seq = iaa.SomeOf((1, 2),
66
[iaa.Fliplr(0.5),
77
iaa.Flipud(0.5),
8-
iaa.Affine(rotate=(0, 360),
9-
translate_percent=(-0.1, 0.1), mode='reflect'),
8+
iaa.Affine(rotate=(-10, 10),
9+
translate_percent=(-0.1, 0.1)),
1010
], random_order=True)
1111

1212

@@ -35,23 +35,37 @@ def __init__(self, pad=None, pad_method=None, name=None, deterministic=False, ra
3535
def _augment_images(self, images, random_state, parents, hooks):
3636
result = []
3737
for i, image in enumerate(images):
38-
image_pad = self._reflect_pad(image)
38+
image_pad = self._pad(image)
3939
result.append(image_pad)
4040
return result
4141

4242
def _augment_keypoints(self, keypoints_on_images, random_state, parents, hooks):
4343
result = []
4444
return result
4545

46-
def _reflect_pad(self, img):
46+
def _pad(self, img):
47+
img_ = img.copy()
48+
49+
if self._is_expanded_grey_format(img):
50+
img_ = np.squeeze(img_, axis=-1)
51+
4752
h_pad, w_pad = self.pad
48-
img_padded = cv2.copyMakeBorder(img.copy(), h_pad, h_pad, w_pad, w_pad,
49-
PadFixed.PAD_FUNCTION[self.pad_method])
50-
return img_padded
53+
img_ = cv2.copyMakeBorder(img_.copy(), h_pad, h_pad, w_pad, w_pad, PadFixed.PAD_FUNCTION[self.pad_method])
54+
55+
if self._is_expanded_grey_format(img):
56+
img_ = np.expand_dims(img_, axis=-1)
57+
58+
return img_
5159

5260
def get_parameters(self):
5361
return []
5462

63+
def _is_expanded_grey_format(self, img):
64+
if len(img.shape) == 3 and img.shape[2] == 1:
65+
return True
66+
else:
67+
return False
68+
5569

5670
class RandomCropFixedSize(iaa.Augmenter):
5771
def __init__(self, px=None, name=None, deterministic=False, random_state=None):

0 commit comments

Comments
 (0)