|
5 | 5 | fast_seq = iaa.SomeOf((1, 2), |
6 | 6 | [iaa.Fliplr(0.5), |
7 | 7 | 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)), |
10 | 10 | ], random_order=True) |
11 | 11 |
|
12 | 12 |
|
@@ -35,23 +35,37 @@ def __init__(self, pad=None, pad_method=None, name=None, deterministic=False, ra |
35 | 35 | def _augment_images(self, images, random_state, parents, hooks): |
36 | 36 | result = [] |
37 | 37 | for i, image in enumerate(images): |
38 | | - image_pad = self._reflect_pad(image) |
| 38 | + image_pad = self._pad(image) |
39 | 39 | result.append(image_pad) |
40 | 40 | return result |
41 | 41 |
|
42 | 42 | def _augment_keypoints(self, keypoints_on_images, random_state, parents, hooks): |
43 | 43 | result = [] |
44 | 44 | return result |
45 | 45 |
|
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 | + |
47 | 52 | 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_ |
51 | 59 |
|
52 | 60 | def get_parameters(self): |
53 | 61 | return [] |
54 | 62 |
|
| 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 | + |
55 | 69 |
|
56 | 70 | class RandomCropFixedSize(iaa.Augmenter): |
57 | 71 | def __init__(self, px=None, name=None, deterministic=False, random_state=None): |
|
0 commit comments