(self, img)
| 53 | self.angles = angles |
| 54 | |
| 55 | def __call__(self, img): |
| 56 | angle = np.random.choice(self.angles) |
| 57 | if isinstance(img, Image.Image): |
| 58 | img = img.rotate(angle, fillcolor=(128, 128, 128)) |
| 59 | return img |
| 60 | elif isinstance(img, np.ndarray): |
| 61 | if angle == 0: |
| 62 | pass |
| 63 | elif angle == 90: |
| 64 | img = np.flipud(np.transpose(img, (1, 0, 2))) |
| 65 | elif angle == 180: |
| 66 | img = np.fliplr(np.flipud(img)) |
| 67 | elif angle == 270: |
| 68 | img = np.transpose(np.flipud(img), (1, 0, 2)) |
| 69 | else: |
| 70 | img = Image.fromarray(img) |
| 71 | img = img.rotate(angle, fillcolor=(128, 128, 128)) |
| 72 | img = np.asarray(img) |
| 73 | return img |
| 74 | else: |
| 75 | raise TypeError('not supported type in rotation: ', type(img)) |
| 76 | |
| 77 | |
| 78 | class RGB2RGB(object): |
nothing calls this directly
no outgoing calls
no test coverage detected